How to Enable SSH on a Headless Raspberry Pi 3

With recent releases of Raspbian (Jessie+) the SSH is disabled by default. The Raspberry Pi foundation has done this to improve security on the many Raspberry Pi’s out there. Leaving SSH enabled by default allows hackers to target your Raspberry Pi and gain access to you system and network if your Raspberry Pi is being run as a web server or connected to the internet. Enabling SSH will allow you to remotely connect to your Raspberry Pi. You will not see the full desktop, only a command line. Using SSH to remotely connect to your Raspberry Pi will allow you to perform updates or install software from another computer on your network.

Objective

To enable SSH on a Raspberry Pi running Raspbian

Material

You will need the following:

Instructions

I will assume you are running Raspbian on your Raspberry Pi. Since we will be running a headless Raspberry Pi, which means no monitor will be connected, we will need to edit the /boot/ folder of our Raspberry Pi SD card. After you burn the Raspberry Pi image onto your SD card open the /boot/ folder on the image and create a file called ssh. You do not need to edit the file or add any content to the file. As long as the ssh file is in the /boot/ partition of the Raspberry Pi you are good to go.

When you boot the Raspberry Pi for the first time it will look for the ssh file and enable SSH if it find the file. The file will be deleted and SSH will now be enabled. You do not need to create the file again after it is deleted. The settings will automatically be saved to your Raspberry Pi.

The /boot/ partition with the created ‘ssh’ file

2 Comments

  • René Sluiter

    September 14, 2018

    if I use this method and disable password login after copying my ssh key to my raspberry, this ssh file will be removed leaving me unable to login on port 22:

    ssh: connect to host 192.168.1.10 port 22: Connection refused

    Reply
    • dayz

      September 14, 2018

      Have you tried creating the SSH file again just to confirm? I feel like maybe there is an issue with your SSH keys instead

      Reply

Leave a Reply