Tutorials

SSH the Raspberry Pi

Overview

In this tutorial you will learn how to to connect remotely to your Raspberry Pi over your local network using a Secure Shell (SSH).

There are several reasons why you might want to connect to your Pi remotely:

  • Your Pi might not be connected to a monitor, keyboard or mouse as you might be using it to control some electronics, like in the Home Automation with the Raspberry Pi tutorial.
  • You might need to install some extra software using GitHub, that even if are able to do it from the Pi LXTerminal or console, sometimes it is a lot easier to do it from a remote computer.
  • When you need to access a console in XBian or other Media Centre distributions it is a lot easier just to start a ssh session from another computer than having to restart to be able to access a console.

What software do you need?

  • In Windows: then you will need to download a free program called putty from here: http://www.putty.org/. Putty is a single file (putty.exe) that you can download to your desktop.
  • In Mac or Linux: If you are using a Mac or Linux PC then open a Terminal. On the Mac, you can find this in the Utilities folder of your Applications folder. In Linux it can be called terminal, console, konsole, LXTerminal, etc depending on the distro you're using.

Finding the Raspberry Pi IP address

The next thing you need to do is finding IP the address of the Raspberry Pi you want to connect to. There are several ways of doing this:

  • From XBian, OSMC, OpenElec or Raspbmc: Have a look to the tutorial Network Setup for a Raspberry Pi Running XBian. The shortcut in XBMC/Kodi is: System -> System Info -> Network
  • From Raspbian: Have a look to the tutorial Network Setup for a Raspberry Pi Running Raspbian. It explains several ways of finding the IP address of the Raspberry Pi.
  • From your router: Some routers allow you to check which devices are connected to them and what's their IP addresses. Sometimes it takes a bit of guessing, but it is just another alternative.

Enabling SSH in XBian

SSH is enabled by default in XBian. But if you need to enable it or disable it you can go to Programs -> XBian-Config->Packages. Then use your keyboard arrows to highlight SSH and press enter. Select Enable Autostart / Disable Autostart. Remember that the default user is xbian, password is raspberry.

Enabling SSH in Raspbmc

SSH is enabled by default in Raspbmc. But if you need to enable it or disable it you can go to Programs -> Raspbmc Settings. Then select the System tab, scroll down to Service Management and enable/disable SSH.

XBMC/Kodi Programs -> Raspbmc Settings -> System Configuration -> Service Management

Enabling SSH in Raspbian

SSH is enabled by default in Raspbian. But if you need to enable it or disable it you can run raspi-config and enable/disbale this service. The tutorial First Boot Configuration for a Raspberry Pi Running Raspbian explains in detail how to use raspi-config.

To enable SSH, once you open raspi-config, navigate to Advance Options -> SSH

Then select if you want the SSH service enabled or disabled.

The following images illustrate this process:

Raspi-Config Advanced Options
Raspi-Config Advanced Options -> SSH
Raspi-Config Advanced Options -> SSH -> Enabled

SSH under Windows

Run putty.exe, enter the IP address of the Raspberry Pi you want to connect to. In this case is 192.168.1.8.

Type it in where it says Host Name (or IP address). Then click on Open.

Running Putty in Windows

The first time you run it it will give you a warning.

Putty Warning

Click on Yes. Then when you get asked you for the user/password:

  • For XBian: user is xbian, password is raspberry
  • For Raspbian and Raspbmx: user is pi, password is raspberry

The ssh window will then be ready for use.

SSH Session Window

SSH from a Mac or Linux

Go to computer where you will SSH from.

Open a Terminal. On the Mac, you can find this in the Utilities folder of your Applications folder.

If you found that the IP address the IP address of the Raspberry Pi you want to ssh to is 192.168.1.8

Enter the following command into the Terminal window.

ssh 192.168.1.8

The first time you run the command, you will get a security warning about not being able to verify the identity of the machine, say that you want to continue.

Then when prompted for the user:

  • For XBian: user is xbian, password is raspberry
  • For Raspbian and Raspbmx: user is pi, password is raspberry

Enter user and hit return/enter, then then enter the raspberry in password (assuming you haven't changed the default password) and hit return/enter.

Test & Configure

Try exploring your files system by using 'ls' to list the files in the current directory and 'cd' followed by a directory name to change the current directory.

You can edit files using 'nano' followed by the file name and also install software using the 'apt-get' command.

When finished with your ssh session, close the client application/window or simply type in exit into the shell window.

Troubleshooting

If you encounter a connection reset by peer error when trying to connect to your Pi, there could be a problem with the SSH keys. You can 'reset' the keys with the following commands.

First, remove the old keys:

sudo rm /etc/ssh/ssh_host_*

Then regenerate them

sudo dpkg-reconfigure openssh-server

Then try again!

 

To build your own media centre, you can get any of the following kits. If you prefer to get a SD card with XBian, OSMC or OpenElec  instead of NOOBS, just write it down in the special instructions when you place an order:

 

 

Raspberry Pi Noobs Kit Transparent - WiFi

Kit includes: Raspberry Pi 2 Model B, Noobs 8GB micro SD card with Adapter, Raspberry Pi black enclosure, HDMI 2m cable, USB power adapter - 5V 2A, USB type A to micro B 1m cable, Network RJ45 1m cable and WiFi USB adaptor with 5dBi antenna: better reception equals faster transfers and no hickups with HD movies, making this adapter ideal for media centres.

$100.80 In stock.
Raspberry Pi Noobs Kit Black - WiFi

Kit includes: Raspberry Pi 2 Model B, Noobs 8GB micro SD card with Adapter, Raspberry Pi black enclosure, HDMI 2m cable, USB power adapter - 5V 2A, USB type A to micro B 1m cable, Network RJ45 1m cable and WiFi USB adaptor with 5dBi antenna: better reception equals faster transfers and no hickups with HD movies, making this adapter ideal for media centres.

$101.80 In stock.
Raspberry Pi Noobs Kit Frosted - WiFi

Kit includes: Raspberry Pi 2 Model B, Noobs 8GB micro SD card with Adapter, Raspberry Pi frosted enclosure, HDMI 2m cable, USB power adapter - 5V 2A, USB type A to micro B 1m cable, Network RJ45 1m cable and WiFi USB adaptor with 5dBi antenna: better reception equals faster transfers and no hickups with HD movies, making this adapter ideal for media centres.

$101.80 In stock.
Raspberry Pi Noobs Kit Rainbow - WiFi

Kit includes: Raspberry Pi 2 Model B, Noobs 8GB micro SD card with Adapter, Raspberry Pi rainbow enclosure, HDMI 2m cable, USB power adapter - 5V 2A, USB type A to micro B 1m cable, Network RJ45 1m cable and WiFi USB adaptor with 5dBi antenna: better reception equals faster transfers and no hickups with HD movies, making this adapter ideal for media centres.

$107.80 In stock.

And then you can add a wireless keyboard, like these ones:

Miniature Wireless USB Keyboard and Touchpad

Add a miniature wireless controller to your computer project with this combination keyboard and touchpad. We found the smallest wireless USB keyboard available, a mere 152mm x 59mm x 12.5mm! It's small but usable to make a great accompaniment to a computer or Raspberry Pi. The keyboard itself is battery powered. The keyboard communicates back to the computer via 2.4 GHz wireless link (not Bluetooth).

$33.15 In stock.
Wireless Keyboard + Wireless Mouse + Learning TV Remote

The perfect media centre remote control. It combines a wireless keyboard, a wireless mouse and a learning infrared remote control. The wireless keyboard and mouse use a 2.4GHz USB dongle. The learning infrared allows the remote control to learn the commands from your existing infrared TV / Amplifier / DVD Player / Blue Ray Player remote controls. Simplify your life with a single remote control.

$52.00 In stock.

You can also check our catalogue for other options.

Comments

There are no comments yet, be the first one to write a comment.
Add comment

* - required field

*




CAPTCHA image for SPAM prevention If you can't read the word, click here.

*
*
Continue Shoppping View Cart
Continue Shoppping View Wishlist