Skip to content

Setup SSH connection on the Raspberry

Joseph Pereniguez edited this page Dec 27, 2018 · 1 revision

1. Set up your local network and wireless connectivity

Make sure your Raspberry Pi is properly set up and connected. If you are using wireless networking, this can be enabled via Pixel's user interface, or using the command line.

If you are not using wireless connectivity, plug your Raspberry Pi directly into the router.

You will need to note down the IP address of your Pi in order to connect to it later. Using the ifconfig command will display information about the current network status, including the IP address, or you can use hostname -I to display the IP addresses associated with the device.

2. Enable SSH

It can be enabled manually from the desktop:

Launch Raspberry Pi Configuration from the Preferences menu Navigate to the Interfaces tab Select Enabled next to SSH Click OK Alternatively, raspi-config can be used in the terminal:

  • Enter sudo raspi-config in a terminal window
  • Select Interfacing Options
  • Navigate to and select SSH
  • Choose Yes
  • Select Ok
  • Choose Finish
  • Alternatively, use systemctl to start the service
  • sudo systemctl enable ssh
  • sudo systemctl start ssh

3. Enable SSH on a headless Raspberry Pi (add file to SD card on another machine)

For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card from another computer. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all.

If you have loaded Raspbian onto a blank SD card, you will have two partitions. The first one, which is the smaller one, is the boot partition. Place the file into this one.

4. Set up your client

You can use SSH to connect to your Raspberry Pi from a Linux computer, a Mac, or another Raspberry Pi, without installing additional software.

You will need to know your Raspberry Pi's IP address to connect to it. To find this, type hostname -I from your Raspberry Pi terminal.

If you are running the Pi without a screen (headless), you can also look at the device list on your router or use a tool like nmap, which is described in detail in our IP Address document.

To connect to your Pi from a different computer, copy and paste the following command into the terminal window but replace with the IP address of the Raspberry Pi. Use Ctrl + Shift + V to paste in the terminal.

ssh pi@ If you receive a connection timed out error it is likely that you have entered the wrong IP address for the Raspberry Pi.

When the connection works you will see a security/authenticity warning. Type yes to continue. You will only see this warning the first time you connect.

In the event your Pi has taken the IP address of a device to which your computer has connected before (even if this was on another network), you may be given a warning and asked to clear the record from your list of known devices. Following this instruction and trying the ssh command again should be successful.

Next you will be prompted for the password for the pi login: on Raspbian the default password is raspberry. You should now be able to see the Raspberry Pi prompt, which will be identical to the one found on the Raspberry Pi itself.

If you have set up another user on the Raspberry Pi, you can connect to it in the same way, replacing the username with your own, e.g. eben@192.168.1.5

pi@raspberrypi ~ $

You are now connected to the Pi remotely, and can execute commands.