Skip to content

Instantly share code, notes, and snippets.

@plembo
Last active May 14, 2022 21:22
Show Gist options
  • Save plembo/60287262f06c42c41e19ca2e656fb2e2 to your computer and use it in GitHub Desktop.
Save plembo/60287262f06c42c41e19ca2e656fb2e2 to your computer and use it in GitHub Desktop.
Raspberry Pi Zero W headless setup

Setup Raspberry Pi Zero W headless

  1. Download desired OS image from https://www.raspberrypi.com/software/operating-systems/ and unzip.
  2. Image SD Card with Raspberry OS:
$ sudo dd if=2021-10-30-raspios-bullseye-armhf-lite.img of=/dev/sdc bs=4M conv=fsync status=progress
  1. Create wpa_supplicant.conf at root of boot partition:
$sudo vi /media/myuser/wpa_supplicant.conf

Contents of wpa_supplicant.conf:

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

network={
     ssid="myssid"
     psk="mywifipassword"
     key_mgmt=WPA-PSK
}
  1. Create ssh file at root of boot partition:
$ sudo touch /media/myuser/boot/ssh
  1. Insert SD Card in Pi and power on.
  2. Login to pi over ssh. Username "pi", password "raspberry".
  3. Change password for pi to something different, passwd.
  4. Set password for root, sudo passwd root.
  5. Do apt update and apt upgrade, sudo apt update and sudo apt upgrade.
  6. Install vim and set editor to vim-basic:
$ sudo apt install vim
$ sudo update-alternatives --config editor
  1. Edit /etc/ssh/sshd_config to make PermitRootLogin yes.
  2. Use raspi-config to:
    • change hostname
    • set locale
    • set timezone
    • expand disk
  3. Test network connectivity (like, ping your gateway and /etc/resolv.conf).
  4. Prevent wifi going to sleep by adding this line to /etc/rc.local just above exit 0:
iwconfig wlan0 power off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment