Connecting the Raspberry Pi Zero W to WiFi without a monitor

Using single-board computers in headless mode—that is, without connecting a monitor, keyboard, or mouse—has become the standard for creating compact IoT devices and servers. Raspberry Pi Zero W It's ideal for such tasks thanks to its built-in wireless module, but initial network setup often leaves users stumped. You don't need a screen; all you need is a PC or smartphone and a microSD card to burn the operating system image.

The entire process is based on creating special configuration files in the root partition of the memory card before the first launch of the device. The system Raspberry Pi OS Automatically detects these files upon boot, applies network settings, and enables remote access. This allows you to manage the device immediately after power-up, saving time and peripheral resources.

This method works for all modern versions of the operating system, including the latest releases based on Debian Bookworm. It's important to follow the syntax of the files you create and correctly identify your device on the local network. Below, we'll cover each step of the preparation and launch process in detail.

Preparing equipment and choosing an operating system

The first step is to select the appropriate operating system image. For the model Raspberry Pi Zero W It is recommended to use Raspberry Pi OS Lite, since this version lacks a graphical interface, it consumes fewer resources and loads faster. The lack of a graphical interface for headless mode is an advantage, reducing the load on the processor and RAM.

You'll need a computer with a card reader to use a microSD card. If you have a laptop without a built-in slot, use an external USB adapter. It's important to use a memory card with at least 8GB of capacity and a Class 10 speed rating to ensure stable system operation and log writing.

To burn the image, use the official utility Raspberry Pi ImagerThis tool not only records data but also allows you to configure WiFi and SSH settings during the recording process, significantly simplifying the process. However, manually creating files gives you more control and insight into the system structure.

⚠️ Note: When using Raspberry Pi Imager, you can directly enter your WiFi information in the settings menu (gear icon). If you use this method, manually creating wpa_supplicant.conf files is not necessary.
📊 Which OS do you prefer for headless mode?
Raspberry Pi OS Lite
Ubuntu Server
DietPi
Arch Linux Archiving

Make sure your router is distributing the network in the 2.4 GHz range, since the WiFi module in Raspberry Pi Zero W does not support the 5 GHz frequency. This is a critical point that is often overlooked by owners of modern dual-band routers.

Creating the network configuration file wpa_supplicant.conf

After writing the OS image to the memory card, but before removing the card from the computer, you need to create a network configuration file. On the disk named boot (or bootfs) create a text file named wpa_supplicant.conf. Please note that the file extension must be exactly .conf, and not .txt.

Inside the file, you need to specify your network parameters. The syntax is important: each command must end with a semicolon, and the block structure must be maintained. For countries with the code RU or US Settings may vary depending on the available channels, so specifying the country code is required.

country=RU

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

update_config=1

network={

ssid="Your_Network_Name"

psk="WiFi_Password"

key_mgmt=WPA-PSK

}

If your network is hidden, add the line scan_ssid=1 inside the network block. For corporate networks with WPA2-Enterprise encryption, the file structure will be more complex and will require specifying EAP authentication methods.

What to do if the password contains special characters?

If your WiFi password contains double quotes or backslashes, they must be escaped with a backslash. For example, the password "My\"Pass" would be written as psk="My\\\"Pass".

File wpa_supplicant.conf It will automatically move to the system partition upon first boot. This means you can edit it on your computer if the network doesn't connect the first time, simply by returning the memory card to the PC.

Activating SSH and setting up remote access

By default in modern versions Raspberry Pi OS protocol SSH (Secure Shell) is disabled for security reasons. To activate it without booting the system, simply create an empty file named ssh (without extension) in the root partition of the memory card.

Just create a text file, name it ssh Don't write anything inside. Upon boot, the system will detect this file, enable the sshd daemon, and immediately delete the file, indicating successful activation. This is standard procedure for all headless installations.

An alternative and more secure method is to add a public SSH key. To do this, go to the section boot a folder is created ssh, and a file is placed inside it authorized_keys with your public key. This will allow you to connect to the board without entering a password.

Parameter Default value Recommended action
SSH port 22 Leave or change
User pi (old OS) / user Change password
Protocol SSH-2 Use only v2
Status Turned off Enable via ssh file

After turning on the device, wait 1-2 minutes for the boot process to complete and network settings to apply. Only then attempt to connect to the device via the terminal.

First boot process and searching for the device on the network

Insert the prepared microSD card into the slot Raspberry Pi Zero W and connect the power. Indicator LED (if connected to the GPIO) should start blinking, indicating disk and network activity. The lack of a monitor shouldn't be a concern: the system is running in the background.

To connect, use the command line on your computer. Enter the command ssh pi@raspberrypi.local (for older OS versions) or ssh user@raspberrypi.local. If the domain name .local If it doesn't work, you'll need to find out the device's IP address assigned by the router.

You can find your IP address through your router's web interface in the list of connected clients. Look for a device with a name starting with raspberrypi or android (depending on the OS version and hostname). You can also use network scanners such as Angry IP Scanner or Fing on a smartphone.

⚠️ Warning: When connecting for the first time, the terminal will warn you about an unknown host key. Enter yesto add the key to the trusted list and continue the connection.

If you are using Windows, the built-in SSH client is available in PowerShell or through the program PuTTYOn Linux and macOS, the standard terminal is sufficient. Make sure your computer and Raspberry Pi are on the same subnet.

Setting up a static IP and managing your network

Server tasks often require that the address Raspberry Pi It hasn't changed. A dynamic IP (DHCP) is convenient, but when you reboot the router, the address may change, which will break your connection scripts. You can configure a static IP via a file. dhcpcd.conf.

After logging in, edit the configuration file: sudo nano /etc/dhcpcd.conf. Add a block specifying the interface to the end of the file. wlan0, desired IP address, gateway and DNS servers.

interface wlan0

static ip_address=192.168.1.150/24

static routers=192.168.1.1

static domain_name_servers=192.168.1.1 8.8.8.8

The specified IP address must be outside your router's DHCP pool range to avoid address conflicts. For example, if your router assigns addresses from 100 to 200, select address 250.

☑️ Checking a static IP

Completed: 0 / 4

After making changes, restart the network service with the command sudo service dhcpcd restart Or simply reboot the board. Now the device will always be accessible at the specified address.

Troubleshooting and Common Errors

If the connection fails, first check the file syntax. wpa_supplicant.confAn extra space, missing semicolon, or incorrect file encoding (should be UTF-8 without BOM) may cause the system to ignore the settings.

A common error is using the wrong WiFi driver or trying to connect to a 5 GHz network. Model Zero W It physically doesn't see the 5 GHz network. Also, make sure the power supply provides sufficient current (at least 1.2 A), as the WiFi module may shut down during peak loads.

For in-depth diagnostics, use the system logs. The command sudo journalctl -u wpa_supplicant will display a history of attempts to connect to the wireless network. You can see the exact reason for the connection failure: incorrect password, timeout, or no network.

⚠️ Note: Network management interfaces and commands may differ depending on the Raspberry Pi OS version. Newer versions (like Bookworm) use NetworkManager, while older versions use dhcpcd.

If nothing helps, try re-creating the network configuration file using the WPA PSK password generator. Command wpa_passphrase"SSID""PASSWORD" will produce a ready-made hashed block that can be inserted into the config, eliminating errors in the password characters.

Additional features and security

After successful connection, it is recommended to change the default user password. pi or create a new user. Standard credentials are known to all attackers and are the main vulnerability of IoT devices on a local network.

Use the command sudo raspi-config for basic system setup. In the menu Interface Options You can additionally enable VNC, SPI, I2C, and other interfaces without manually editing configuration files. This is especially convenient when working without a monitor.

Consider installing Fail2Ban to protect your SSH from brute-force attacks. This utility blocks IP addresses after several unsuccessful login attempts. While this is overkill for a home server, it's critical for a device accessible from the outside world.

Update your system regularly with the command sudo apt update && sudo apt upgradeCurrent packages contain fixes for security vulnerabilities, which is especially important for devices that operate continuously on the network.

How to reset WiFi settings?

If you change the network and the card doesn't connect, simply insert the card into your PC and edit wpa_supplicant.conf again—the changes will apply the next time you turn it on.

FAQ: Frequently Asked Questions

Is it possible to set up WiFi via Bluetooth if there is no Ethernet port?

Yes, Raspberry Pi OS has Bluetooth PAN enabled by default in some versions, but for the Zero W it's more reliable to use the file-on-memory-card method, as pairing without a screen is difficult to control.

What is the maximum WiFi range of the Raspberry Pi Zero W?

Due to the compact antenna and small board size, the range is shorter than that of full-size models. In open spaces, it's about 10-15 meters, and indoors, 5-8 meters.

Does the ssh file method work on Raspberry Pi OS Bullseye and Bookworm?

Yes, the method for creating an empty file ssh in the boot partition works on all current OS versions. However, in the Bookworm version, the user is disabled by default. pi, so you may need to create a new user immediately after logging in.

Why is my Raspberry Pi not visible on the network after creating files?

Check whether your router supports the encryption protocols used by the card. Also, make sure AP Isolation isn't enabled on the router, which prevents devices from seeing each other.