SSH is one of the most friendly deamons in the Linux toolbox, you can port forward your home server, you can surf the internet via your own proxy server, you can transfer files, it’s the first thing I set up on a freshly installed box and by far the most used service around my home (yeah, that’s nerdy) :-)
This post will outline how you can create a public and private RSA key pair, and then we will use that key pair to authenticate ourselves to another computer in the network.
We will need to complete the following steps:
- Create a public/private rsa key pair
- Copy the public key to the remote host via ssh-copy-id
- Login to the remote system without a password
Create a public/private rsa key pair
If you haven’t created a rsa key pair yet, we can create it with this command:
As shown in this screenshot:
For my home machines I don’t use a passphrase, if you’re more paranoid (or careful) you can do so. Please read this article for more info on passphrases and how to use them.
The keys have been generated in /home/yourloginname/.ssh and are called id_rsa and id_rsa.pub.
Never, never send someone your private (id_rsa) key! That is the same as handing over your house keys..
Copy the public key to the remote host via ssh-copy-id
This step should be repeated for all hosts to which you want to SSH with the newly created RSA key pair.
The command used is:
ssh-copy-id -i ~/.ssh/id_rsa email@example.com
You will need to enter your password one last time, after that your public key is added to the authorized_keys file, which is automatically created on the target system.
After this step you don’t need to use a password any more!
Login to the remote system without a password
Just SSH into the remote system:
And wonder what you’re gonna do with all that extra time you’ve just won because entering passwords belongs to the past… :-)