Setup Stage 3 – Configuring SSH

If you don’t know what SSH is or what it can do for you, check out the the articles Secure Shell on Wikipedia

Before we begin check out the blog entry Generating an SSH key pair

As we start to build our super computer we don’t want to have to access each of the PI’s by connecting them to separate screens, keyboards and mice. Instead we’ll connect them only to the network and access all of the Pi’s from a computer using SSH and so we don’t need to enter a password everytime we log in, we’ll use secure keys to take care of this.

To make sure everything is working, first SSH into your pi with the following command, substituting the name keith for the name you used.

ssh keith@raspberrypi

Enter the password you set for the user, and this should log you into a terminal on the remote raspberry pi. It should look something like this

When you are happy you are logged in, exit back to you computer by just typing ‘exit’

Next we need to create a pair of keys, this is done by entering the command ‘ssh-keygen’ as below and follow the prompts for entering the pass phrase which secures the keys

Keys come in a pair, a public and private part. We give the public part to any system we want to connect to and keep the private part secret to ourselves.

They keys are stored in a folder called ‘.ssh’, you can see them by entering the command ‘ls .ssh’ as below

Once we are happy the keys have been generated we need to copy the public key to the system we want to connect to. This is done using the scp command as follows

scp .ssh/ keith@raspberrypi:~

Once this is done, ssh again into the raspberry pi using the same commands as above

ssh keith@raspberrypi
mkdir .ssh
cat >> .ssh/authorized_keys

You can now SSH again into the raspberry, but this time it won’t ask you for the password as it uses your key instead

ssh keith@raspberrypi

Most of this information was taken from the following website How to use RSA Key for SSH Authentication

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