I have installed wifi-connect inside the container and configured the WiFi of RPi Zero W successfully.
I want to get the WiFi passphrase of the currently connected AP from the container, but nmcli command is not working:
nmcli -s -g 802-11-wireless-security.psk connection show <SSID>
But I can see <SSID>.nmconnection file at /etc/NetworkManager/system-connections/ directory of the hostOS, which has the psk information I want to get.
How can I read the nmconnection file on hostOS from a container?
I’ve just run the following command in a container:
nmcli -s -f 802-11-wireless-security.psk connection show resin-wifi-01
and got back the passphrase for my connection. I think you can’t specify the SSID, you have to specify the name of the system connection. I also had to issue:
# SSH into the yokoso container:
ubuntu@ubuntu-desktop:~$ sudo balena ssh 192.168.1.115 yokoso
# Check if the environment is set correctly:
root@yokoso:/usr/src/app# printenv | grep DBUS
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
# Get connection list:
root@yokoso:/usr/src/app# nmcli -g NAME connection show
resin-sample
supervisor0
# Get psk of `resin-sample`:
root@yokoso:/usr/src/app# nmcli -s -g 802-11-wireless-security.psk connection show resin-sample
root@yokoso:/usr/src/app# nmcli -s -f 802-11-wireless-security.psk connection show resin-sample
802-11-wireless-security.psk: --
root@yokoso:/usr/src/app# exit
exit
Connection to 192.168.1.115 closed.
# SSH into the hostOS:
ubuntu@ubuntu-desktop:~$ sudo balena ssh 192.168.1.115
Last login: Tue Oct 20 12:33:45 2020 from 192.168.1.103
# Well, it has `resin-wifi`??? instead of `resin-sample`?
root@yokoso:~# ls /etc/NetworkManager/system-connections/
README.ignore resin-sample.ignore resin-wifi
root@yokoso:~# ls /mnt/boot/system-connections/
README.ignore resin-sample.ignore resin-wifi
root@yokoso:~#
So, resin-wifi is actually used to configure the wifi, but I cannot see it on container? but seeing resin-sample instead?
Looks like the connection added by wifi-connect (resin-wifi) is not recognized by nmcli independently from where it is called. I am wondering if this will work after a device reboot …
root@yokoso:/usr/src/app# DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket nmcli c s
NAME UUID TYPE DEVICE
resin-sample 1669d9b1-30a7-3d20-87ec-aad518cd9e8f wifi wlan0
supervisor0 15f1b362-7469-4e49-84de-367020f45a65 bridge supervisor0