How do I add the server port number to ssh-copy-id?

I use

ssh-copy-id  "-p $SERVERPORT  -i /home/$USERNAME/.ssh/vpn-server.key.pub $SERVERUSERNAME@$SERVERIPV4"

or

ssh-copy-id  -i /home/$USERNAME/.ssh/vpn-server.key.pub "-p $SERVERPORT  $SERVERUSERNAME@$SERVERIPV4"

is not correct

ssh-copy-id  -i /home/$USERNAME/.ssh/vpn-server.key.pub   $SERVERUSERNAME@$SERVERIPV4

so you can run

Thank you.

Jun.15,2021

see ssh-copy-id 's man manual:

SSH-COPY-ID(1)                                                       BSD General Commands Manual                                                       SSH-COPY-ID(1)

NAME
     ssh-copy-id  use locally available keys to authorise logins on a remote machine

SYNOPSIS
     ssh-copy-id [-f] [-n] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname
     ssh-copy-id -h | -?

however, I remember that the ssh-copy-id of centos 6 and ubuntu 12.04 does not support port parameters. I saw its source code (pure shell script) at that time, but there was no resolution of port parameters. At that time, I remember that I had hack its source code, and I added the port parameter to achieve this requirement. So there's still some impression here. Later higher versions of ssh-copy-id append the port parameter to specify the SSH port number. If your ssh-copy-id does not support the specified port number, you can only manually append your public key to the ~ / .ssh/authorized_keys of the remote server.

in fact, this is how the source code of ssh-copy-id is written


  1. -p parameter
ssh-copy-id -p
  1. modify / etc/ssh/ssh_config

modify Port to your port number

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e462df-438cb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e462df-438cb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?