Raspberry Pi - Bookworm Network Configuration

Raspberry Pi - Bookworm Network Configuration

I recently bought a raspberry pi zero 2W based on a suggestion from a good friend. I struggled quite a lot in setting up ssh access in the latest Raspberry Pi OS (Bookworm). I was trying to setup my raspberry pi in headless mode. While doing so, I referred to many articles and videos recommending to add and configure wpa_supplicant.conf file and placing an empty file named ssh in the boot folder.

On research, I found out that the recent raspberry OS have removed dhcpd and have started using NetworkManager rendering the wpa_supplicant.conf file redundant. This short article is to help anyone struggling with the same configuration.

Once you have flashed the latest RaspberryOS (Bookworm) with either RPI-Imager or through balena etcher/rufus (whatever is your preferred method) in your SD card. Read the SD card through a reader or a provided port through your PC/Laptop.

When the SD card is mounted, you need to navigate to the root partition as shown below :-

To ensure you have mounted the correct partition, it will contain a bunch of folders like these :-

Navigate to /etc/NetworkManager/system-connections

Over here make sure you are using admin privileges to create a nmconnection file :-
<yourSSID>.nmconnection and make sure that the owner is root as NetworkManager demands it. You can do so with the following two commands :-


sudo chmod 600 <yourSSID>.nmconnection
sudo chown -R root:root <yourSSID>.nmconnection
[connection]
id=<Your SSID>
uuid=00000000-0000-0000-0000-000000000000
type=wifi
interface-name=wlan0

[wifi]
mode=infrastructure
ssid=<Your SSID>

[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=<WIFI Password>

[ipv4]
method=auto

[ipv6]
addr-gen-mode=stable-privacy
method=auto

[proxy]

You nmconnection file should have these details as shown above. For writing to this file, make sure you are opening the file with root privileges.

Now, we can insert the SD card into our raspberry PI and on boot up, it will successfully connect to your configured wifi.

Et Voila, You can then ssh inside your pi without any troubles.