how do I attach devices to connections using nmcli?
The short answer is:
# nmcli con modify my-bridge connection.interface-name ens7
# nmcli con up my-bridge
However, it's never that simple - read on...
Three things are needed for the connection to be attached to the device:
- A valid network device
- The
connection.autoconnect
property to be set toyes
- The
connection.interface-name
property is set to the name of the interface
Make sure that you have a working NIC (virtual in a VM). This is outside the scope of this answer as there are so many options.
Check the state of the connection.autoconnect
property with:
# nmcli con show my-bridge | grep connection.autoconnect:
connection.autoconnect: no
and if need be, change it with:
# nmcli con modify my-bridge connection.autoconnect yes
Check the state of the connection.interface-name
with:
# nmcli con show my-bridge | grep connection.interface-name
connection.interface-name --
and if need be, set it with:
# nmcli con modify my-bridge connection.interface-name ens7
The easiest would be
nmcli device wifi connect <name ssid> password <the password>
For a solution with the password as variable: https://github.com/aurelien-git/bash/blob/master/wifi.sh
This script offer you the choice of selection and hidden passord