SSH without password

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:

  1. Create a public/private rsa key pair
  2. Copy the public key to the remote host via ssh-copy-id
  3. 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:

ssh-keygen

As shown in this screenshot:
Screenshot from 2014-07-28 21:28:18If you have previously created a key pair, you will be asked to replace this.
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 joris@192.168.0.10

Screenshot from 2014-07-28 21:30:35
 
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:
Screenshot from 2014-07-28 21:32:01
And wonder what you’re gonna do with all that extra time you’ve just won because entering passwords belongs to the past… 🙂
 
 

One Reply to “SSH without password”

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.