Introduction
Last week I released a guide to setting up the Raspberry PI 2 Model B. Of course, as my age is kicking in, it obviously slipped my mind that I had already released another guide showing how to do the same thing back in March 2015. At least they both show how to do it in different ways.The new guide simply shows how to install the latest version of Raspbian whereas the guide back in March showed how to install NOOBs.
In this guide I am also covering a bit of old ground but it is updated for the Raspberry PI 2.
Today's tutorial will show you how to connect to the Raspberry PI command line using Linux, Windows and Android.
Turn On The Raspberry PI SSH Server
The first step is to turn on the Raspberry PI. Hopefully you should see the Raspbian screen as shown above.
If your Raspberry PI boots straight to the command line type startx.
Click the menu in the top left of the screen, select preferences and then Raspberry PI Configuration.
The Raspberry PI Configuration settings screen will appear.
There are four tabs:
- System
- Interfaces
- Performance
- Localisation.
Take a note of the hostname on the system tab (or remember it if you can)
Also take a note of the auto login user (i.e. auto login as 'pi')
Click on the Interfaces tab.
The SSH option is the 2nd item down on the list. Make sure the "Enabled" radio button is selected.
Click "OK".
If asked to do so reboot the Raspberry PI.
Connect Raspberry PI To The Internet
You will need to make sure the Raspberry PI is connected to a network. If you are at home connecting the Raspberry PI to the internet will achieve this aim.
Click on the network icon in the panel as shown in the image above and choose a wireless network to connect to. You will need to enter your wireless network's security key.
If your Raspberry PI is connected via ethernet cable you don't need to do this as it should already be connected.
SSH To The Raspberry PI 2 From Linux
To connect to the Raspberry PI 2 from a computer running Linux such as Ubuntu, Mint, Elementary, Debian, Fedora etc open up a terminal window.To connect to the Raspberry PI 2 enter the following command:
ssh pi@raspberrypi
In the above command replace the word pi with the name of the user you use to connect to the Raspberry PI 2 and the hostname of your Raspberry PI 2.
A message may appear asking whether you want to continue. If it does type yes.
You will now be asked for your Raspberry PI password.
At this point you will now be logged in to the Raspberry PI from the command line and you can run command line software and scripts.
SSH To The Raspberry PI 2 From Windows 10
Windows is supposed to be easier than Linux isn't it? Actually in this case it is a little bit more difficult.Within Linux all you have to do is open a terminal and type ssh pi@raspberrypi. In Windows there isn't a default ssh client.
There is also the problem that it is more difficult to find the Raspberry PI or its IP address on the network.
The method I am going to show isn't the most efficient but it is the easiest.
First of all on your Raspberry PI open a terminal window. You can do this by clicking the 3rd icon on the panel along from the menu button. (the little computer symbol next to the file manager).
Now within the terminal type the following commands:
sudo apt-get update
sudo apt-get install samba
sudo reboot now
Wait for the Raspberry PI to reboot.
It is now time to get around to installing a tool for connecting via SSH to the Raspberry PI.
Open the Windows 10 Store (It is the little shopping bag icon on the panel).
Type "ssh" into the search bar. Click on the option for "Remote Terminal" (it is a free application).
After Remote Terminal has installed open the application.
Choose "SSH" as the type and type "raspberrypi" into the host (or your Raspberry PI's hostname that you wrote down earlier).
Enter "pi" as the username (or your Raspberry PI's username that you wrote down earlier).
Leave the authentication method as "Password".
Click "Connect".
A message will appear asking whether you wish to continue. Press "Y".
Another message will appear asking whether you want to store the host in the cache. Again press "Y".
Now enter the password for your Raspberry PI user.
You should now be connected to the Raspberry PI.
After trying the quick connect option you should try the add option. This gives you the option of creating a saved connection so that you can get to the Raspberry PI more quickly in the future.
Enter a name such as Raspberry PI and leave the type as "SSH".
Finally enter the hostname and username for the PI as you did for the quick connect option. Leave the authentication method as password.
Press save.
Now when you run the Remote Terminal application you will see an option for the Raspberry PI.
SSH To The Raspberry PI From Android
You will need an Android tablet or phone for this. (I recommend a tablet because how are you going to type into the SSH terminal within a tiny phone).
Within the Play Store search for and install ConnectBot.
Open the ConnectBot app.
Press the button to bring up the menu on your tablet or phone and select "settings".
Click on "Emulation Mode":
The options for emulation mode are as follows:
- xterm-color
- xterm-256color
- xterm
- vt100
- ansi
- screen
Choose the xterm option.
Exit the settings screen and you should see the screen with the message "Use the quick-connect box below to connect to a host" displayed.
In the ssh box at the bottom type pi@raspberrypi
You will be asked if you want to continue due to the authenticity of the host not being established, Click "Yes".
Enter the Raspberry PI password.
You will now be connected via ssh to the PI.
Summary
You can now connect to the Raspberry PI for all tasks that don't require a graphical user interface.
In the next guide I will show you how to connect via VNC so that you don't need your Raspberry PI connected to a physical screen any more.