5333 private links
Distribution of SSH keys
When you want to allow public key authentication, you have to first create a SSH keypair. Next step is then the distribution of the public key to the other systems. Let’s have a look at a few options, including using the ssh-copy-id utility.
Option 1: Manually
In the past, you had to log in manually to the new system and do things yourself. Especially if you created your key with a tool like PuTTYgen on Windows. Then you logged in on the other system, created a .ssh directory and the related authorized_keys file. Of course, it was common to forget setting the right permissions, resulting in the authentication to fail.
Option 2: Using ssh-copy-id
Much easier is to use the SSH utility ssh-copy-id. Just run the tool and provide it your username on the remote server, with the remote server name.
ssh-copy-id michael@my-server
It will use your local environment to determine the related key(s) and copy it over. In case you use an alternative identity file, you can provide that with the -i option. Same for when running on a different port, specify it together with -p. To simplify your life, set up a ssh_config file. This way the right username and port are used.