ssh-copy-id - use locally available keys to authorise logins on a remote machine
ssh-copy-id [-f] [-n] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname
Options you will use
-i identity_file- the public key to copy (default: the newest of ~/.ssh/id*.pub)
-f- force: do not first try to log in with the key to check whether it is already installed
-p port- connect to this port
-o ssh_option- passed to ssh
Examples
$ ssh-copy-id web-1log in once with the password, append ~/.ssh/id_ed25519.pub to ~/.ssh/authorized_keys there
$ ssh-copy-id -i ~/.ssh/deploy.pub deploy@db-1another key, another user
Gotchas
- It needs one working login (usually the password). On cloud images PasswordAuthentication is off: then the key goes in through cloud-init / the provider, not ssh-copy-id.
- It creates ~/.ssh (700) and authorized_keys (600) on the remote side; a group-writable ~/.ssh makes sshd ignore the key (StrictModes).
Try ssh-copy-id in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.