/ Raspberry Pi

Add SSH and WiFi to a Headless Raspberry Pi

This is an update to a previous post on the same subject. In that post, I made the process a lot longer than it needed to be. But that's mostly due to my learning while doing... The process, as I lay out below, is much more streamlined to get you from no SSH/WiFi to a connected headless unit. Go!

After the Burn(ing)

Once you get your image burned to your SD card (I use Etcher) you'll want to remount the card. That's usually as easy as removing it (properly, of course) and reinserting it. On my Mac, I can see it's mounted in Finder. Once it's mounted you can open up Terminal/Shell to get started.

SSH

The good folks at the Raspberry Pi Foundation have made your Raspbian image more secure than in years past. You used to be able to just plug in the card and SSH was enabled by default. However, that's no longer the case. You, the end user, need to add a file to do just this. Fortunately, it's easy to do. In Terminal (again, I’m on a Mac, your destination may differ):

sudo nano /Volumes/boot/ssh

This will open a blank file within the nano editor called ssh. If you were to just hit Control + X, Y, Enter to save as normal it won't save anything. So, just type in a letter and delete it (backspace) so the file is blank again. Now you can hit Control + X, Y, Enter to save it. You'll now have a blank file called ssh. DO NOT CLOSE TERMINAL.

If you're planning on running a wired connection to your RPi (recommended if you're running a web server!) then you can skip to the "Finish Up" section below. However, if you're also wanting to get WiFi working out of the gate (think RPi Zero or Zero-W) then let's move to the next section.

WiFi

Much like above we need to create a new file via our nano editor. In Terminal:

sudo nano /Volumes/boot/wpa_supplicant.conf

This is the file that tells your RPi what SSID/Password to use for your WiFi. The file contents under the new Stretch Raspbian image is a little different than it used to be. However, the nice thing is you can use the new contents even if you're using Jessie or earlier. Within this new file copy/paste this into it:

country=US 
ctrl_interface=DIR=/var/run/wpa_supplicant 
GROUP=netdev 
update_config=1 

network={
ssid="your_real_wifi_ssid"
scan_ssid=1
psk="your_real_password"
key_mgmt=WPA-PSK }

The things YOU need to change are your_real_wifi_ssid to your real SSID and the your_real_password to your WiFi password associated with the actual SSID. Once edited you can save your work (Control + X, Y, Enter) and you'll be back at the $ prompt. DO NOT CLOSE TERMINAL YET

Finish Up!

So you've created and edited one or two new files. To finish up the process all you need to do it type:

exit

This will close out the files. From there you just "properly" unmount the SD card from your computer and insert it into your RPi. Upon boot, your little computer should have WiFi enabled and/or SSH auto enabled. Now be sure to update your password via passwd and update your system.

Wait... what's my Raspberry Pi's IP?

Good question. The easiest way to get this is to do a local ping on your network. Via Terminal:

ping -c 1 raspberrypi.local

This is telling your computer to ping the local host raspberrypi only one time. Without the "1" it'll just keeping pinging it until you hit Control + C or close Terminal. The output will give you what you're looking for.

[youtube https://www.youtube.com/watch?v=jr0JaXfKj68&w=560&h=315]

Then it's just a matter of:

ssh [email protected]

Happy Pi(ing).

Add SSH and WiFi to a Headless Raspberry Pi
Share this