Raspberry Pi Zero Headless Setup - pre April 2022
Since the Raspberry Zero comes with only Wifi I will go into further detail how to use the Zero with headless setup.
0. Preperation:
Get the latest Raspbian OS Lite Image from the offical website and flash it with BelenaEtcher to your SD-card.
After flashing you will get 2 partitions:
1. boot
2. root
The boot partition is accessable via file explorer in Windows which leads to the next step.
1. Configuration
1.1 Activate SSH-Service:
According to the official instructions (para. 3), a file called ssh must be created in the root directory of the boot partition. The mere existence of this file in the Raspian boot process causes the OpenSSH server to be automatically activated and accept incoming connections on port 22. This is necessary since we are not going to plug in any peripherals.
1.2 Wifi-configuration:
The second step is a bit more extensive. The wpa_supplicant.conf file is also created in the root directory of the boot partition. According to unverified statements, it must have Linux line endings. As announced in the background information, this file is automatically moved to the "correct" location /etc/wpa_supplicant/ on startup.
Config content for copy & paste
country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="WLAN SSID"
scan_ssid=1
psk="WLAN PASSWORT"
key_mgmt=WPA-PSK
}
The values WLAN SSID and WLAN PASSWORD must of course be replaced by the actual information. If you are not in Germany, DE is to be replaced by the ISO code of the current country.
1.3 Startup
This completes the preparations. The SD card is now inserted into the Raspberry Pi and then connected to the power. After a few seconds the Raspberry Pi should appear in the WLAN, raspberrypi is used as the default hostname. In the WLAN access point you should also be able to determine the assigned IP address.
With your SSH-Client of choice you can connect to the Raspberry Pi directly. The default credentials are pi:raspberry. You should change that asap.