Raspberry Pi – WiFi and SSH on First Boot

How to setup your Raspberry Pi to connect to your WiFi the first time you boot up and to allow you to SSH into it from another machine on first boot.

This is useful if you use your Raspberry Pi headless (that is without a screen, attached), and want to use it without plugging it into a network (Raspberry Pi Model A’s or Zero W’s for example).

The first thing you will need to do is burn an image to your SD card using your favourite method. Once done, eject the card – and remove it from your reader. Then plug it back in to the same computer.

Look for the “Boot” drive to be mounted in Windows – or mount it if your using Linux.


If you are using Windows, then find a good editing tool. I recommend Notepad++ as it saves in the correct format without a lot of Windows padding added in.

Open your tool of choice and create a new file with the following contents

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


You will need to edit some of the lines as follows:

Line 1: country
This tells the Raspberry Pi what WiFi regulations apply. You need to get the right country codes as each country allow different frequencies to be used. You can find your correct country code on Wikipedia: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#GB

Line 6: Replace the text wifi_ssid with the name of your WiFi hotspot

Line 7: Replace the text wifi_password with your WiFi password

Now, save this to the “Boot” drive identified earlier and save the file with a file name of “wpa_supplicant.conf”


To enable SSH on first boot, on the boot drive identified earlier, create a blank text file called simply “SSH”. No extension (.txt for example).