Headless Raspberry Pi Zero W setup with SSH and Wi-Fi
Got your first Raspberry Pi? Missing a mini-HDMI adapter, or micro-usb keyboard?
Raspberry Pi’s are capable of running just like any computer, full displays and window management, keyboards and mice, but you probably don’t intend to set one up on your desk and leave it there.
More than likely your intent is to use it for a motion-sensitive webcam, IoT device or intelligent adapter or controller.
Once you have your Raspberry Pi setup and deployed, remote management will be required, SSH will be ideal, and you probably didn’t want to install an extra 2.7GB worth of window management anyway.
Here’s what we’ll cover:
- Download Raspbian latest
- Format your MicroSD card
- Write the image to your MicroSD card
- Mount the image
- Enable SSH
- Configure Wi-Fi
- Gracefully eject your MicroSD card
- Boot your Raspberry Pi
Before we begin, it’s worth noting that the steps I’ll cover are primarily for OS X, however, most of the steps only require small adaptations for other operating systems.
Step 1. Download Raspbian Latest
The latest image of Raspbian is available from
Step 2. Format your MicroSD card
You’ll want to use a MicroSD card that you can erase for the rest of these instructions. Disk Utility won’t cut it here, however there is SD Card Formatter available from
Choose “Overwrite Format” and specify a new name for the card, for this example I called it “RaspberryPi”.
Step 3. Write the image to your MicroSD card
These steps are relatively well documented in the Raspbian installation guide, follow the instructions here for your preferred host OS.
My take on the OSX instructions (10.12 Sierra in this case) were straightforward, diskutil list will list connected media, you’re looking for something like /dev/disk#.
$ diskutil list
$ diskutil unmount /dev/disk#
$ sudo dd bs=1m if=/path/to/raspbian-jessie.img of=/dev/disk#
This is all that was necessary for me, however the instructions were extensive and provide workaround for issues that I didn’t encounter. Once the image is written, the boot partition should immediately become available, however, the root partition will not if you’re running OS X.
Step 4. Mount the image
Now that you have the image written to the MicroSD card, you’ll need to mount it before you can customize it. This is where things get a little awkward. OS X doesn’t support Ext filesystems, and needs a little extra help.
FUSE for macOS (or osxfuse) can help us mount the filesystem, I previously had osxfuse installed to mount AWS S3 buckets, but the installation should be straight forward.
With osxfuse installed, we now need to install fuse-ext2 which will help us mount EXT2/EXT3/EXT4 filesystems. The setup instructions are relatively straight forward, you may not already have an /opt/gnu/bin folder, so you may need to create that first.
Additionally, during the e2fsprogs steps, I may suggest symlinking the files from /opt/gnu/lib/pkgconfig to /usr/local/lib/pkgconfig rather than copying them to make future cleanup easier.
Step 5. Enable SSH
Assuming you named your boot partition RaspberryPi (as I did above):
$ touch /Volumes/RaspberryPi/ssh
Enabling SSH is as simple as that, Raspbian will look for a file named ssh on the boot partition at startup and will enable sshd, which by default is disabled.
Step 6. Configure Wi-Fi
With Step 4 complete, and your root partition mounted under /Volumes/Raspbian, we’ll need to update the wpa_supplicant.conf with a network preconfigured.
Edit /Volumes/Raspbian/etc/wpa_supplicant/wpa_supplicant.conf and add your network to the end of the file:
After editing, the file should look something like:
Step 7. Gracefully Eject your MicroSD card
osxfuse will want to hold onto that mounted filesystem, you’ll need to find the process (Activity Monitor, or ps aux) and kill the process, you should then be able to eject from Finder.
Step 8. Boot your Raspberry Pi
Insert the MicroSD card into your Raspberry Pi and connect it to power. If all of the above steps went well, it should start up, enable sshd, automatically connect to your wifi.
The Raspberry Pi should pick up an IP address from your local DHCP server, so you’ll either need to guess the IP, or use your router admin interface to list the connected clients.
Pro-tip: If you’re using an Apple Airport, option-double-click on your Airport in Airport Utility to view the list of connected clients.
Once you’ve got the IP address of your fresh Raspberry Pi, you’ll be able to access it via ssh, the default password is raspberry:
$ ssh email@example.com
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
Congratulations on setting up your Raspberry Pi! Don’t forget to change your password!
Edit: Ok, one last step. Adding the ssh file to the boot partition is only temporary, the file is removed on startup and sshd won’t start on subsequent startups.