Raspberry Pi Course Week 6 - Day 1 SSH

SSH is a method of connecting to the Raspberry Pi in a secure manner from a remote computer or device.  Using this method will allow you to run a headless Raspberry Pi.  What this means is that you do not have to have a monitor or TV connected to it in order to see what is happening.

Your remote computer will send commands to the Raspberry Pi and will display results on the remote computer.  To send remote commands to the Raspberry Pi you will need a program to send these commands.  Any terminal from a Linux computer or another Raspberry Pi will allow you to do this but if you are using a Windows computer then you will need another type of program.  One such program is called PuTTY which acts as a secure terminal to connect to remote devices.

The ssh server is installed on some distributions and it started by default and can be enabled or disabled using raspi-config.  To access this program enter the following from the command line.

$ sudo raspi-config

If you do need to install SSH then following the installation instructions below.

Enter the following to install the SSH.

$ sudo apt-get install ssh

The next step is to start the daemon in the background.  Remember daemons are programs that run in the background.

$ sudo /etc/init.d/ssh start

Assuming that all the computers and the Raspberry Pi are connected to the same network, you will need the IP address or the Raspberry Pi.  Enter the following to obtain the IP address of the Raspberry Pi.

$ sudo ifconfig

Make a note of your IP address.  This can be found next to the line inet addr.

The first example will use PuTTY.  Click here to download PuTTY.

Follow the instructions for installing PuTTY and when the installation is complete, run PuTTY.  Enter the IP address of the Raspberry Pi and make sure that port the port number is 22 and that SSH has been selected.

Raspberry Pi ssh

Click on the Open button.  After a few seconds a black terminal window will appear asking you for your login.  Enter pi as the login and raspberry as the password.  If you have changed your login details then just replace the details.

You are not executing commands on the Raspberry Pi from a computer.  To confirm that you are connected to your Raspberry Pi enter the following.

 $ uname -a

You should see a message displaying the Raspberry Pi version.

The only problem with the SSH server is that in its present state, it won’t start each time it is booted.  To make the SSH server run each time enter the following.

$ sudo update-rc.d ssh defaults

Reboot the Raspberry Pi and connected to the Raspberry Pi using PuTTY.

If you are using a linux or Raspberry Pi to connect remotely then all you need to do is enter ssh followed by the IP address of the Raspberry Pi that you are trying to connect to.  Log into your Linux operating system or the first Raspberry Pi and enter the following.

$ ssh 192.168.100.25

You are now logged into the remote Raspberry Pi.  To exit the remote Raspberry Pi just type exit.

Raspberry Pi Course Week 6 - Day 2 MySQL Database

Next Raspberry Pi Databases MySQL – Week 6  Day 2.0 >>