Change or delete preset Wi-Fi settings?

How do I rewrite Wi-Fi information remotely using balena console?

Thank you :wink:


BalenaOS uses Network Manager to manage it’s network connections. When you connect to the host OS of the balena device, you can use the nmcli command to update/rewrite network configurations. But be aware when doing this remotely, that if it does not work out as expected, you might not be able to connect to the device again. Depending on your use case might also be interesting to you. This tool can create a local AP, that allows to configure Wi-Fi credentials for the the device via a web interface.

1 Like

Hi @afitzek

I have confirmed that it is possible to change Wi-Fi settings remotely with nmcli.

However, when resin-wifi-01 exists, it was restored to the original WiFi setting by restarting.

The following method was used to solve this.

  1. remove resin-wifi-01
$ rm /mnt/boot/system-connections/resin-wifi-01
  1. delete SSID by nmcli
$ nmcli connection delete [WIFI_SSID]

Thanks for your answer.

Hey @kazuph,

I have had to do this in the field a few times and wanted to add my experience. Note to other readers that what @afitzek is all very true. It is dangerous to do this kind of thing because if interrupted at the wrong time you might be saying goodbye to your device forever. Network manager in my experience is terrible at picking between multiple connections.

So @kazuph is doing more or less the same thing but there are some differences. Anyways this is how I replace wifi settings in the field.
I echo in a new connection like this:

echo "[connection]




" > /mnt/boot/system-connections/NAME_OF_CON

Then I confirm it with:

cat /mnt/boot/system-connections/NAME_OF_CON

Then I deleted the old connection from the two places you need to:
rm /mnt/boot/system-connections/resin-wifi-01
rm /mnt/state/root-overlay/etc/NetworkManager/system-connections/resin-wifi-01

Note the top one is the one that persists between boots and OS upgrades, and the bottom is bound to NM here: /etc/NetworkManager/system-connections/ so it delete thing here as well

Then I restart the device and that makes NM forget the old connection and the /mnt/boot file get moved to the right spots by balenaOS. I like this process because it ensures the replacement connection is there before you delete the old one. You could also put the new connection in both those places we removed the old one from and test it with nmcli c up YOUR_CON_NAME because if it fails it will probably try the old one again and let you back in.

Good luck to anyone that has to do this. I don’t do this with our fleet anymore because I wrote a python network manager supervisor that does all this for me and fills in some of network managers weak points for my fleet.


1 Like