Enabling SSH on Rasberry Pi

I am a big fan of Raspberry Pi’s.

For a while I attempted to use them as network monitoring servers, but the older versions of the board were not very stable and if they had a power hiccup it would destroy the SD card it was running off.

However with the version 3 boards, I have not had any issues. I have been using one running “PiHole” as a DNS server for my household, and another one running OctoPi, which is running my 3D printer. Both have been rock solid.

There is an issue however with the initial configuration. In both the above examples, there is no mouse/keyboard/display, they are “headless”. And for (perfectly legitimate) reasons, by default SSH is not running Rasbian (the most popular Raspberry Pi OS based on Debian). Since I didn’t want to go through the effort of setting up a mouse/keyboard/display just to get SSH running, I found another way. From the official documentation:

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.

The tricky part afterwards is finding it on your network. You can either look in your router’s DHCP logs to see which IP address was just assigned, or you could port scan your entire network for devices listening on port 22. (Maybe you will find something you weren’t expecting!) The default username is “pi” and the default password is “raspberry”.

Two hints regarding Raspberry Pi’s:

  • If they are going to be running “headless” just use an ethernet cable and plug it directly into your router. Just one less thing running over your wireless network. And give it a static IP address!
  • Put it on a UPS. Although I don’t have any evidence to back this up, my experience has been that SD cards do not handle cold reboots very well.

Wooooo FRIDAY NIGHT.

UPDATE: To add the “ssh” file to SD card via Windows 7:

  1. Open command prompt
  2. Navigate to root of “boot” partition of SD card
  3. Run command “copy NUL ssh“. This creates an empty file called “ssh”.

Update: On MacOS run

touch /Volumes/boot/ssh
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *