SSH authorization key for multiple systems

The authorized_keys file on a remote host can contain more than just one public key. Just append them – make sure that each key gets a new line.

To simplify this process, there is ssh-copy-id(1).

ssh-copy-id user@machine-B

You can execute the above command on Machine C. It will copy the default public key to Machine B and append it to authorized_keys automatically. You can also specify another public key to be copied by using the -i option if you want.


Here's the reference in the manual:

The user creates his/her key pair by running ssh-keygen(1). This stores the private key in […] ~/.ssh/id_rsa.pub (protocol 2 RSA) in the user's home directory. The user should then copy the public key to ~/.ssh/authorized_keys in his/her home directory on the remote machine.

The authorized_keys file […] has one key per line, though the lines can be very long. After this, the user can log in without giving the password.


Alternatively, you can run this command:

cat id_rsa.pub | ssh remote-user@remote-host "cat >>~/.ssh/authorized_keys"

In order to append to the authorized_keys file