How to set up a headless Raspberry Pi Zero W

Arindam Basu
2 min readJun 5, 2023

--

… quite amazing what this little device can do!

I have become quite a fan of the little Raspberry Pi Zero W (w stands for wireless). It is a tiny little computer smaller than a mouse you use with your computer and has a single board computer with 512 MB RAM and you bring in the SD card and an OS. We used a headless installation of the Raspberry Pi and set up a server. The chip is inexpensive and you will need a power brick (Raspberry Pi makes the power brick) to go with it, if you choose to go the “headless” way. Here are the steps to set up a server with the raspberry pi zero w using the raspberry imager:

Step 1: Prepare the SD card

  1. Start with a blank sd card and flash the raspberry pi image or raspberry pi os image to the blank micro sd card.
  2. Remove and reinsert the micr sd card into your computer and cd into the bootfs directory
  3. Create three files: ssh, userconfig.txt , and wpa_supplicant.conf with the following contents:
  • Leave the ssh blank. So, if you use a Mac or Linux, type touch ssh at the prompt in the bootfs folder
  • For the userconfig.txt add the following line as the first and the only line:

pi:xxxxxxxxx where xxxxxxx is obtained from

echo ‘raspberry’ | openssl passwd -6 -stdin` 

(source: https://www.raspberrypi.com/news/raspberry-pi-bullseye-update-april-2022/). Note the code generated and copy the text. Then paste the text in place of xxxxxx

  • The wpa_supplicant.conf file contains the following:
country=nz
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
scan_ssid=1
ssid="MyNetworkSSID"
psk="Pa55w0rd1234"
}

(Source: https://www.raspberrypi-spy.co.uk/2017/04/manually-setting-up-pi-wifi-using-wpa_supplicant-conf/)

Substitute “nz” for the two letter ISO code for your own country; you can find the list from here: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes

Step 2: Find and boot into Raspberry Pi device

After completing these steps, remove the microsd card from the computer and then insert in the Raspberry Pi slot, then power up the Pi device with its supplied power brick. You will need to find out the raspberrypi IP address. You can find that using the nmap tool with the following command:

sudo nmap -sn 192.168.1.0/24 and look for the lines where they state the figures for raspberrypi device. Note down that number. Then open a terminal and type:

ssh pi@xx.xx.xx.xx where xx.xx.xx.xx is the IP address of the raspberry pi device you found in the previous step.

Once you in the device, create new users and start your journey with this fantastic device. You can set up servers, or use it for many other uses.

--

--

Arindam Basu
Arindam Basu

Written by Arindam Basu

Medical Doctor and an Associate Professor of Epidemiology and Environmental Health at the University of Canterbury. Founder of TwinMe,