Raspberry Pi: Configure WLAN/WiFi before first boot

Posted by Valentin Heidelberger on Monday, September 10, 2018 Tags: Technology Linux RaspberryPi   1 minute read

Why

Lots of Raspberry Pis are used for purposes requiring a wireless network connection. Configuring WLAN for the Pi requires a config file including the network’s name and access keys. To save time otherwise spent on connecting the Pi to a screen and keyboard or wired network to configure this, you can just create the config file before even booting the Pi for the first time. Here’s how that works.

How

Having flashed the Raspbian image onto your Pi, use your file explorer or terminal to move to a newly created partition called “boot” on the micro SD card. Create a file called wpa_supplicant.conf in the root of that partition and paste the following contents in there. Change the country parameter as well as the ssid and psk accordingly and save the file:

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

network={
     ssid="Your network name/SSID"
     psk="Your WPA/WPA2 security key"
     key_mgmt=WPA-PSK
}

Once the file is modified and saved, eject the SD card safely, put it in your Pi and boot it up. You should be able to connect via SSH using the default user pi and password raspberry shortly after.