Enable SSH (Secure Shell) on the Raspberry Pi

3

Secure Shell or SSH is a network protocol that allows you to run commands on a remote device. In the case of the Raspberry Pi can you execute commands over your network from another device such as a PC or laptop. This allows you to control the Pi without attaching a keyboard, mouse or even a monitor.

If configured correctly you can use SSH to communicate with your Pi over the internet.

The latest version of Raspbian (November 2016) disables SSH by default for security reasons. If you need to use it then it must be enabled.

Method 1 – Temporary Use

To start the SSH server on a Pi you can open a terminal window (i.e. LXTerminal) and type :

sudo /etc/init.d/ssh start

followed by Enter. This needs to be done every time the Pi boots.

Method 2 – Enable Permanently from the Command-line

From the command line start by running the following command :

sudo raspi-config

This will launch the raspi-config utility. Select “Advanced Options”.

Enable SPI Using Raspi-config

The Advanced options let you enable/disable various interfaces.

  • Select the “SSH” option.
  • Set the option to “Yes”
  • Select “OK”
  • Select “Finish”

When prompted select “Yes” to reboot so that the changes take effect.

Method 3 – Enable Permanently from the Desktop

If your Pi boots to the desktop you can either “Shutdown” and use Method 2 or use the graphical tool “Raspberry Pi Configuration”. This is found under Menu > Preferences > Raspberry Pi Configuration

raspiconfig_gui_01

Then you simply need to select the “Interfaces” tab and set SSH to “Enabled” :

Raspberry Pi Configuration

When prompted select “Yes” to reboot so that the changes take effect.

Method 4 – Enable Permanently

The methods above assume you already have access to the Pi and can connect remotely or have a screen attached. This method allows you enable SSH on the SD card directly in another computer.

To enable SSH automatically every time the Pi starts you need to :

  • Prepare a fresh SD card with the latest version of Raspbian
  • Insert the SD card in your PC
  • Create a file on the boot partition named “ssh”
  • Eject the SD card, insert into your Pi and power it up

When the Pi boots SSH is enabled by default.

Using SSH on a PC

The free utility “PuTTY” can be used to connect to your Pi using SSH once it is enabled. This will allow you to type commands as if you were using the Pi directly.

You can even use SSH to transfer files using a file explorer style interface on your PC. I recommend the free utility WinSCP which will allow you to drag and drop. Transferring files is easy and similar to using FTP.

Using SSH on an Android Phone

I use the “Juice” application to connect via SSH on my Android Smartphone.

Share.

3 Comments

  1. Thanks for the post. You have a mistake in your post for Method 2. You have ‘Rename “boot_enable_ssh.rc” as “boot.sh”‘. That’s the wrong file extension. It needs to be “boot.rc”.

    After following your directions ssh was still not working. I happened to look inside the file boot.sh file and it says in the top comments ‘Name this file as “boot.rc” and put it on the boot partition’.

    Please update your post for others. Thanks for the lead.

    Happy Pi’ing! 🙂

Leave A Reply