Enable SSH on Raspberry Pi

Isn’t SSH Enabled by Default Already?

The short answer is no. The slightly longer is that it was enabled on the Raspberry Pi until the November 2016 release of Raspbian when the developers decided to turn off SSH by default. This led to much googling and swearing from me because If you’re quadriplegic, you can’t just stick a keyboard and monitor into your Raspberry Pi and diagnose the problem. Everything is done via ssh.

Why the Change

The developers outlined the thoughts behind the change here and I largely agree with them, nobody wants millions of zombie Raspberry Pis rampaging over the Internet and taking out Reddit now do we. Then where would we be?!

So What Do We Do to enable SSH By Default?

Anyway, to get around this problem just install the Raspbian Operating System onto a class 10 SD Card. When the process is finished we need to place a small file called ssh in the root partition of your SD card.

So for me when I’d run the command to install Raspbian and waited for it to finish:

Install Raspbian onto an SD Card

This is outside the scope of this post, but Here are some instructions I wroteon how to flash SD cards if you don’t already know how to.

Put the ssh File on Your SD Card

Flashing done, Simply open up your Terminal and on macOS typing the following command which will create a small file called ssh on your SD card. I’m not sure where your SD card will be mounted if you’re using Linux or Windows, so your mileage may vary. But you do need that ssh file to be present if you want to be able to immediately SSH into your Raspberry Pi.

This is the command:

touch /Volumes/boot/ssh

Once you’ve successfully ssh’d in to your Raspberry Pi (using ssh pi@your_pi_ip_address), it’s a good idea to just quickly check on the status of the ssh service. You do that with the following command:

Check Your SSH Service Status

systemctl status ssh.service

If all is well you will see something very similar to the words “Active: active (running)” in the output of the command, if you don’t then you need to manually enable ssh.

You can enable or disable the SSH service using the raspi-config tool which I wrote a little tutorial about here. But it basically boils down to these three steps:

Activate raspi-config

sudo raspi-config

Select Interfacing Options

From the menu that appears when you invoke raspi-config use the down arrow to highlight option number five, then press return to select it:

5 Interfacing Options  Configure connections to peripherals

Enable SSH

From the next menu select the second option by highlighting it using the down arrow key and pressing enter. Then on the next page press the tab key until the word <Yes> is highlighted and press return to select it.

P2 SSH Enable/Disable remote command line access

You will then be returned to the main menu where you can either make other modifications to your configuration or press the tab key until the word ____ is highlighted and reboot your Raspberry Pi to finish the process.

Conclusion

Let me say again that I love the Raspberry Pi, I really do. This is the first time the Raspberry Pi Foundation has done anything that has even mildly inconvenienced or annoyed me. And this problem was solved pretty quickly after I actually thought to post on their Github documentation repository issues page.

So yes, buy more Raspberry Pis and if you get stuck just drop me a line in the comments and I’ll see if I can help.