If you’re anything like me, you’re somewhat paranoid security-minded.

Because of this, you’ve most likely moved the SSH port on your server(s) to something other than the standard port 22.

Nothing wrong with a little bit of security through obscurity on top of all of the other crap you’ve done to lock things down.

Unfortunately, one time I had locked myself out of a box because I had failed to copy over my private key before changing the port number.

Frustrating, but nothing a bit of digging around wouldn’t solve.

Prior to OpenSSH 6.2:

ssh-copy-id "[email protected] -p ####"

Since OpenSSH 6.2:

ssh-copy-id -p #### [email protected]

You could also go the route of adding the port to your ~/.ssh/config:

Host hostname
  HostName #.#.#.#
  Username username
  Port ####

Then use ssh-copy-id hostname as you normally would!