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)
NAME
ssh-copy-id - install your identity.pub in a remote machine's authorized_keys
SYNOPSIS
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/public_key_for_host_1.pub 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/public_key_for_host_1.pub "-p 54329 user@host"
Correct Directory Permissions for Troubleshooting:
$ chmod 700 ~/
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/id_ecdsa
$ chmod 600 ~/.ssh/authorized_keys