FreeBSD Linux UNIX

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 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.