Setting up SSH to use key pairs

If you SSH to the same server a lot and don’t want to type the password each time you can configure SSH so you don’t have to.

First login to your terminal as normal and run

$ ssh-keygen

This will ask you the name of the key pair file you want to use.
It will suggest ~/.ssh/id_rsa
It will also create an id_rsa.pub file.

Next you need to “copy” that file to the server you want to connect to, you do by using the ssh-copy-id command.

$ ssh-copy-id user@hostname

You will be prompted for your password one last time, but from that point on you should be able to connect without using your password.

NOTE: If you want to do the same thing to another host, all you need to do is use the ssh-copy-id command again and replace the hostname with the new hostname.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.