2

From the docs:

Previous versions of Raspberry Pi OS made use of a wpa_supplicant.conf file which could be placed into the boot folder to configure wireless network settings. This is no longer possible from Raspberry Pi OS Bookworm onwards.

I'd like to know if there is an alternative method that does not need a GUI application to correctly configure WiFi on the Raspberry Pi OS image.

Question: How can I configure WiFi on an Raspberry Pi headlessly without using the Raspberry Pi Imager in current Raspberry Pi OS images?

3
  • 1
    what I would do is create an image using the RPi Imager with the settings you want, then check the boot partition for a file called firstrun.sh - you'll see what needs to be done - also check cmdline.txt to see how firstrun.sh is being executed - everything you need to know is in the file /usr/lib/raspberrypi-sys-mods/imager_custom if you can read shell scripts Nov 2 at 23:36
  • Good question... absent any explanation from the "pi guys", I'd say that's a pretty shitty move... in effect requiring use of their RPi Imager app to create a bootable SD that works for headless versions of the OS. (I define bootable as capable of hosting an SSH connection via Enet or WiFi.) I've not yet tried to install 'bookworm' so I've not had to deal with this. It's possible this is something they've not gotten around to yet - we'll see shortly. In the meantime, I'd try @JaromandaX 's suggestions.
    – Seamus
    Nov 3 at 0:09
  • I just added wifi (I had it turned off) on a pi running bookworm by running sudo /usr/lib/raspberrypi-sys-mods/imager_custom set_wlan 'ssid' 'psk' 'CC' (I hope the actual values to use are obvious) - then rebooted Nov 3 at 0:12

2 Answers 2

0

Bookworm now uses NetworkManager for networking.

I believe it is possible to specify network configuration, after all Raspberry Pi Imager does this (I guess by creating a .nmconnection file) but AFAIK this has not (yet) been documented (it is still early days for Bookworm).

Unfortunately this is not the full picture for headless setup. For some time Raspberry Pi OS has required that a user be generated on first boot - Raspberry Pi Imager can also do this. This was explained in https://www.raspberrypi.com/news/raspberry-pi-bullseye-update-april-2022/

0

With Raspberry Pi OS bookworm you can configure WiFi via a custom.toml that you place in the bootfs partition (first boot only).

Note that this feature is experimental and will be replaced by cloud-init in the future.

An example gist and blog explains some of the options:

I am copying the example from the aforementioned gist (not affiliated):

# Required:
config_version = 1

[system]
hostname = "raspberrypi"

[user]
# If present, the default "rpi" user gets renamed to this "name"
name = "rpi"
# The password can be encrypted or plain. To encrypt, we can use "openssl passwd -5 raspberry"
password = "$5$pN7oRnie.WDOHoJY$aWEYmKUytN/S/bxMza5ksBiurbSJmcvcysBKHSmYa45"
password_encrypted = true

[ssh]
# ssh_import_id = "gh:user" # import public keys from github
enabled = true
password_authentication = false
# We can also seed the ssh public keys configured for the default user:
# authorized_keys = [ "ssh-rsa ... user@host", ... ]

[wlan]
ssid = "mywifi"
password = "$5$pN7oRnie.WDOHoJY$aWEYmKUytN/S/bxMza5ksBiurbSJmcvcysBKHSmYa45"
password_encrypted = true
hidden = false
# The country is written to /etc/default/crda
# Reference: https://wireless.wiki.kernel.org/en/developers/Regulatory
country = "IE"

[locale]
keymap = "gb"
timezone = "Europe/London"

You could dig more into the firstboot or init_config scripts (the latter is what loads the config).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.