Configure Wifi Settings on Raspberry Pi Zero 2 W using the SD Card
-
To setup a new WiFi connection on the Raspberry Pi using only the SD card, you will need to create a new file in
/etc/NetworkManager/system-connectionscalledMySSID.nmconnection. Replace theMySSIDwith the name of your network, if your network has spaces create it like this:sudo nano 'My Network With Spaces.nmconnection'.For the contents of the file, it needs to look like this:
[connection] id=My Network With Spaces uuid= type=wifi [wifi] cloned-mac-address= mode=infrastructure ssid=My Network With Spaces [wifi-security] key-mgmt=wpa-psk psk=My Network Password [ipv4] method=auto [ipv6] addr-gen-mode=stable-privacy method=auto [proxy]Be sure to change
idandssidto be the name of your network, you don’t need to add quotes if there are spaces in your networks name. Also be sure to changepskto be your network password. When you are done useCtrl+Xto save the changes.Now we need to restrict the file’s access rights because NetworkManager requires it to be only accessible by root:
sudo chmod -R 600 /etc/NetworkManager/system-connections/MySSID.nmconnection
sudo chown -R root:root /etc/NetworkManager/system-connections/MySSID.nmconnectionNow you should be able to automatically connect to your WiFi network during the next boot.