Last Updated: February 25, 2016
·
921
· victor

Easy and trouble-free copying your SSH public key to a server

In order to be able to log in to a remote server over SSH without needing to provide the password everytime, you need to generate a couple of keys, and then copy the public one to the server.

Since this is a process that you only do once (per server, that is) and is prone to errors (because you need to remember the right key file, set the permissions right and so on), it is better to use the ssh-copy-id command.

The simplest way to use it is as follows:

$ ssh-copy-id remoteuser@remoteserver

This will copy your public key file (by default, ~/.ssh/id_rsa.pub) to the remote server ~/.ssh/authorized_keys file, creating it if it doesn't exist, or appending to it if there are already existing keys.

If you need for some reason to provide a different key, just pass it on with the -i argument.