Copy Public Keys using ssh-copy-id to remote servers

ssh-copy-id is a utility which comes with the OpenSSH package.


ssh-copy-id copies your public identity keys to the remote server, in the correct format, makes sure file permissions and ownership are correct, and ensures a private key is not accidentally copied.



To Generate the keys (If you have not done already) :

# ssh-keygen -t rsa

This is will create your public and private keys and will place them by default in .ssh folder in your home directory.

To setup password less login (key based login), you need to append your public key to the authorized_keys file on the remote server which you want to setup the key based authentication.

You can do conventional copy/paste, etc.. But it takes much time and its repetitive job for multiple hosts. 


To avoid this, you can copy using the following command, which makes your job much easier


# ssh-copy-id -i  ~/.ssh/id_rsa.pub  root@server2


Using key-based authentication instead of passwords, makes it easier to manage multiple remote systems.

Share this

Related Posts

Previous
Next Post »

What do you think about this Article? Add your Opinion..! EmoticonEmoticon