Knowledge for the World

How to set up WiFi on your Raspberry Pi without a keyboard or monitor (or ethernet)

I'm one of the rare software developers that doesn't have an extra HDMI monitor, keyboard, and ethernet connection ready to go at a moments notice. So in the past, setting up a new Raspberry Pi has been tricky. Fortunately, you can now configure a WiFi connection on the Raspberry Pi without having to first connect to ethernet.

1

If you don't have Raspbian installed, go ahead and install it. Make sure the SD card with Raspbian is in your computer.

2

You'll have to locate the boot directory, on my Mac it's in /Volumes/boot.

cd /Volumes/boot

3

Create a file in this directory called wpa_supplicant.conf. The file should contain the following details:

For Raspbian Jessie:

network={
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

For Raspbian Stretch:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

With this file in place, Raspbian will move it in /etc/wpa_supplicant/ when the system is booted.

The next step is to boot the Pi and test, but while the SD card is still in your computer I'll mention this now. If you're going to try to connect via SSH, you may need to enable it first. The process is similar to this one.

4

The next step is to put the micro SD card into the Pi, boot, and then try to connect via WiFi.