Introduction: Enabling SSH in Raspbian PIXEL

About: FPV Pilot, RC Fanatic, broken NextCloud Server too many times to count. Latest projects include whole home audio system based on Forked-DAAPD and Shairport-Sync as well as some IOT development.

So I've mentioned earlier that due to the Mirai botnet the Raspberry Pi Foundation has decided to disable SSH settings by default in all versions of Raspbian PIXEL from this past November, 2016. What this means is that in order to enable SSH, you have to either connect the Pi to a monitor and enable it from within the GUI, or you have to add a specific file to the boot directory immediately after you initially flash the firmware. However, it's important to remember that you can update your distro right from the command line using sudo apt-get dist-upgrade and SSH will remain enabled, just make sure you change the default passwords, or even restrict the Pi user from using the SSH server.

This process is only necessary for fresh installs of Raspbian!!

This Instructable is pretty simple, but I would say that it's good to know at the very least. In April I'm probably going to release an Instructable on setting up NextCloud, as it was recommended to me by a user and it looks to be a lot better than OwnCloud, or a two part series in April to May on a whole house audio system based on AirPlay. I'm still finalizing both of these, but just wanted to put it out there as to what you can look for in the future!

Step 1: Flash the SD Card

The first step of a new install is going to be to flash the SD card with the latest firmware. If you don't have that downloaded, click on the link below to get the latest version of PIXEL from The Raspberry Pi Foundation.

Once it's downloaded, unzip the file and place the image file in a place where you'll remember it. Chances are you'll be needing to re-flash sometime in the future.

Now that that's done, write the image to the SD card using Win32DiskImager, a process I explained in depth in my OwnCloud Instructable.

A little tip on this, when you delete files off of anything, the system just marks these files as empty space, and they are not actually deleted. Windows cannot understand Linux partitions, and so it would make sense that this goes both ways. For example, if you have an old install on your card, and you flash the board with new firmware, you may find that the files and programs that were on there before are still there. If this is a problem for you, format the SD card using SDFormatter before you flash it with the disc image, and make sure that you have the full overwrite option selected. I'm not totally sure of the validity of any of this, but I think that it happened to me recently, and if true, is definitely something to know for future projects where performance is necessary.

Step 2: Create Your Text File

In order to enable SSH without ever touching a monitor, you have to add a file to the boot directory (The files you can see when the SD card is plugged in to the computer). This file will be scanned on the FIRST boot and it will tell the system to enable the SSH server. Notice how this is only going to work on the first boot, if you sty it afterwards, it will not work and you will have to start again.

So to begin, open NotePad, and you will get a blank text document. For my purposes, and yours, it doesn't matter what's written in the file, so I leave it blank, but of course if you want to add text for some reason, it doesn't matter. The important thing is the title when you save the file.

Click on "File" and go down to "Save As" and in the dialog box that pops up, type in "ssh" for the title of the file. This will save the text document without an extension, so that it will be read by the Pi on boot. The title must be ssh, so make sure that it is called ssh in the boot directory, not ssh.txt or anything else.

Once you're satisfied, move the file to the boot directory on the SD card, which is literally just the files that you can see on the card from your PC, and that's it.

Step 3: Connect!

Now, you should be able to connect to the Pi via SSH on you home network, simply plug in the SD card, along with the necessary cabling, and let it go. Once you're in, the first thing that I would recommend doing is to change the password for the user Pi by typing passwd into the terminal. (NOT sudo passwd, this will change the root password, not the user password.) I usually then add a separate user (Me) that I will operate the Pi from, and I recently learned how to restrict ssh access to certain users, like Pi, which I will be doing for sure. Just Google it if you want to know how, I'm not totally sure how off the top of my head.

If you don't know the Pi's IP address, or just want a better way to connect, try Termius. I saw it a little while ago, and it's pretty good with the Windows and iOS clients. All you have to do is create a host with the necessary information about the user, and it just works. It's not as reliable as PuTTy, but it's not a bad option. (I'll be sticking with PuTTy, and maybe trying out OpenSSH)

You can learn more here.

Not super interesting, but next month definitely look out for a NextCloud or Audio System tutorial!