Setting Up the Raspberry Pi Zero W as a Headless Server

The other day I was fortunate enough to be able to purchase a Raspberry Pi Zero W from Adafruit. You can’t beat a fully functioning $10 wireless computer. I, of course, wanted to setup the Zero W as a headless server but I couldn’t directly plug it into my network due to the lack of an Ethernet port.

Luckily I found a post that gives directions on how to setup the RPi Zero W to automatically connect to a wireless network.

After installing a fresh Raspbian image on an SD card, mount the root partition (not the boot partition) by using a fuse-ext2 on a Mac or another Linux distribution.

Open the network interfaces file for editing.

$ sudo nano /etc/network/interfaces

Modify the following section from

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

to

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Next, edit the wpa_supplicant.conf file.

$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add your network information to the end of the file.

network={
  ssid="your network name"
  psk="your network password"
  proto=RSN
  key_mgmt=WPA-PSK
  pairwise=CCMP
  auth_alg=OPEN
}

Enabling SSH for A Headless Raspberry Pi

On November 30th, 2016, the Raspberry Pi Foundation decided to disable SSH by default in Raspbian for securing reasons. I understand the decision and fully support it. This, of course, is a little inconvenient for those of us that setup our Raspberry Pis as headless servers and don’t want to pull out peripherals and monitors every time we want a fresh setup. Luckily there’s a solution.

Simply create an empty file labeled ssh in the boot directory after the Raspbian image is installed.

$ touch /bootmountpoint/ssh