Setup Stage 4 – Updating the system

Now we can login without a password using SSH and our secure keys

Working behind a proxy

If you are behind a proxy server, then you need to follow the following instructions. If you are not behind a proxy server, or don’t know what one is then just to the next section Updating your system

Its a bit of a catch 22 now, before we explore updating the system with apt-get we need to set it up to access files on the internet from behind a proxy.

The proxy configuration is stored in the a folder at /etc/apt/apt.conf.d/. Change to this folder and the create a blank file called ’10proxy’ using the commands as they are below

Enter the following details into the empty file, substituting the IP address and port below with the details of you own proxy server and port.

Save the file by pressing esc and the enter !wq

Updating your system

To update our system using the command ‘apt-get’. Enter the following command and the system will chunter away from a while updating the base system with anythiing that has changed since it was installed,

Next enter the following command to install a better editor than ‘vi’, this again will chunter away and install an editor called ‘vim’

 
sudo apt-get install vim

Once Vim is installed we can edit some of the basic configuration files when we login.

cd ~
vim .bashrc

This will load the file .bashrc into vim, its quite a large file so we don’t display it here, but scroll down until you find the following

Remove the # from the beginning of the lines which contain the command ‘alias’ so it looks like this

If you are not behind a proxy you can skip this section and you are done, otherwise, scroll down to the bottom and enter the following line

export http_proxy="http://10.150.37.4:8080"

Substituting the IP address and port below with the details of you own proxy server and port making sure its the same IP and port you used above when configuring the proxy settings for apt-get, so that it looks something like this

You are now done, press esc and the enter !wq to save the file and exit, and thats it, we are ready to start installing all manner of magic software needed by a super computer

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/id_rsa.pub keith@raspberrypi:~

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

ssh keith@raspberrypi
mkdir .ssh
cat id_rsa.pub >> .ssh/authorized_keys
exit

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

Setup Stage 2 – Network Configuration

Now that you have an SD configure with the base system, we need to configure the network so that we have a static ip address and unique name for each pi.

When the pi boots by default it will grab a dynamic ip address via dhcp and have the default hostname of raspberrypi, but we are going to have 5 Pi’s on our network so each needs its own name, plus we want to ensure that each Pi always boots with the same ip address.

First we edit the network configuration file

sudo vi /etc/network/interfaces

Which will look something like this

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

The network card is called eth0, and we need to change it from dhcp to static ip address. Edit the file, so it looks like use. You can use whatever ip address that works for your network. For this super computer I am going to use 192.168.1.200 – 192.168.1.205 for the Pi’s

auto lo

iface lo inet loopback
iface eth0 inet static
    address 192.168.1.201
    netmask 255.255.255.0
    gateway 192.168.1.254

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

We will set the other 4 Pi’s as do the individual per Pi configuration later

Next we need to edit the hostname file so that each Pi has a unique name

sudo vi /etc/hostname

Replace raspberrypi with unique name, for the first device I’ll use pislave1, and the configure 3 as pislave2, pislave3 and pislave4 and also have a pilaster which will control the 4 slaves

 

Setup Stage 1 – Create a new user

So we’ve burnt an SD card, and installed our base operating system, we’ve booted the card and configured the base operating and rebooted it and logged in with out ‘pi’ user. Now its time to create a user, and install the base tools including updating the operating system

After you have logged in, its best to create a user other than pi that will do all the work, as pi is the default user and its nice to have a user that is you 😉

We create a user using the ‘adduser’ command. Enter the following command and you’ll see the system respond with something similar. Everytime ‘adduser’ asks you a question you can just press enter as the default answer is always fine at this stage

pi@raspberrypi ~ $ sudo adduser keith
Adding user `keith' ...
Adding new group `keith' (1002) ...
Adding new user `keith' (1002) with group `keith' ...
Creating home directory `/home/keith' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for keith
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
pi@raspberrypi ~ $

So we now have a user created. To allow this user to be able to modify the system we have to give this user super user privileges, and this is a 2 stage process

The first stage is to use the ‘visudo’ command which brings up the file containing the list of all users with ‘su’ or super user priviledges.

pi@raspberrypi ~ $ sudo visudo

This will bring up the following screen

Underneath the line pi = ALL(ALL) NOPASSWD: ALL, enter a new line using the user you created above, the line should read keith = ALL=(ALL) ALL, and the result should look like this

To save and exit, type Ctrl-O remove the .tmp extension from the file, hit enter and the hit Ctrl-X to exit.

The next stage is to complete adding the user to su privs, enter the following command

pi@raspberrypi ~ $ sudo adduser keith sudo

Generating an SSH key pair

ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cantin/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/cantin/.ssh/id_rsa.
Your public key has been saved in /home/cantin/.ssh/id_rsa.pub.
The key fingerprint is:
f6:61:a8:27:35:cf:4c:6d:13:22:70:cf:4c:c8:a0:23 cantin@sodium

First Boot – Configuring your Pi

Right you have a Pi, and a power supply, and and its hooked up to some sort of monitor and TV and you’ve followed the instructions to format your SD card with Debian, its time to boot the little beauty and get it configure.

Pop in the SD card, insert the power supply and watch as the screen springs to life showing all sorts of operating system code. Nothing to worry about, watch it with awe as the OS boots and goes through its basic checks.

The first time the OS boots it starts with the following screen which is a program called raspy-config and allows you to configure the basic parameters of the operating system.

Its menu drive and easy to use with just a keyboard. No shinny shinny GUI here for you windows and mac users, this is hard code command line !!

First option displays some information about the tool

Press the cursor keys until <OK> turns red and the press OK, this takes you back to the previous screen.

Move to the next option which allows you to repartition the SD card to use all of the available memory rather than the 500M of the image you downloaded

The work will not take please until you reboot ( see below ), so as soon as you press OK it returns to the main menu

Next we set the keyboard. I use an old Mac keyboard, but you should search the list for the right version, the next menu then allows you to select more specific version of the keyboard

The next few options can be skipped through by selecting OK as they are more about configuring keys that you’ll use with Windowing system, but we are building a super computer and don’t need them

Again skip through this section

And this one…

Once you return to the main menu, the next option is to change the password for the default user ‘pi’

When you select this option, you’ll be prompted to enter a new password

After you have entered it and then reconfirmed it, it will confirm everything has been changed. You’ll need this password at the end of this section to log into the Pi

Next we set the memory usage. I tend to stick with the default option of using as much for the OS and the minimum for the graphics as we are doing super computer cool stuff not fancy windows stuff on this project

Next we set the overclocking options. Take note of the warning. If you are not comfortable with this process leave this option at default.

If you have a Rev 2 board then you can use the Turbo mode which runs the Pi at 1Ghz.

I’ll write a whole article about overclocking and the options for really binning your board later

Next we enable the SSH server. This will provide us a mechanism to log into each of the machines from your PC or Mac rather than attached a mouse and keyboard and monitor to each device.

Finally we select the boot option to not boot straight into X windows instead just the command line when the Pi starts.

You can easily start the windowing system with the command starts from the command line at any time once you are logged in

Finally select to reboot the Pi to finish the configuration

Select to restart and the system will reboot and you’ll see the text scroll past as before. However this time if you elected to extend the file system across the whole of the CD card above, then it will pause while it carries out this work.

This can take anything up to 5 mins for a 16GB card, so be patient, eventually the system will continue…..

Thats it, its booted and running, to login enter username pi and the password you entered during the password stage above

Next steps are to create a new user and install all the software to create an amazing super computer platform….