- Inserted the SD card into your Windows PC.
- Opened the boot partition folder inside VS Code.
- Created a file named exactly
firstrun.sh.
- Changed the line endings in VS Code from CRLF to LF so the Pi could read the file.
- Pasted a bash script into the file to inject your network details into NetworkManager (the network tool used by newer Raspberry Pi OS versions).
- Entered your specific Wi-Fi name and password.
- Put the card into the Pi 5 and powered it on.
- Used the Windows Command Prompt to run
ping raspberrypi.localto locate its new network IP address.
firstrun.sh
#!/bin/bash
# Create the NetworkManager connection file
cat << ‘EOF’ > /etc/NetworkManager/system-connections/preconfigured.nmconnection
[connection]
id=Preconfigured-Wifi
type=wifi
autoconnect=true
[wifi]
mode=infrastructure
ssid=YOUR_WIFI_NAME
[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=YOUR_WIFI_PASSWORD
[ipv4]
method=auto
[ipv6]
method=auto
EOF
# Set required strict security permissions for NetworkManager
chmod 600 /etc/NetworkManager/system-connections/preconfigured.nmconnection
chown root:root /etc/NetworkManager/system-connections/preconfigured.nmconnection
# Optional: Enable SSH so you can access it headlessly
systemctl enable ssh
systemctl start ssh