ssh-copy-id Utility

ssh-copy-id is a helpful command that simplifies the process of sending a user's public key to a remote host's authorized_keys file.

From the man page:

SSH-COPY-ID(1)                                                  SSH-COPY-ID(1)
       ssh-copy-id - install your in a remote machine's authorized_keys
       ssh-copy-id [-i [identity_file]] [user@]machine

The ssh-copy-id command is helpful for a couple of reasons. First is the bit about it handling permissions for a given user's home, ~/.ssh, and ~/.ssh/authorized_keys directories and file. Incorrect permissions here can be a bump in the road during the process of setting up ssh keys, so to have permissions taken care of by the command is helpful. Second, I appreciate not having to cat or scp the public key into the authorized_keys file of the host machine where public key is being added.

Example syntax:

ssh-copy-id -i ~/.ssh/ user@host

In the case that the sshd daemon on the host you are sending your key to runs on a non-standard port (ie. not port 22), use the following syntax:

ssh-copy-id -i ~/.ssh/ "-p 54329 user@host"

Correct Directory Permissions for Troubleshooting:

$ chmod 700 ~/
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/id_ecdsa
$ chmod 600 ~/.ssh/authorized_keys


 SSH  Linux utilities