Today I need to setup a wifi connection on a laptop to my home network with hidden SSID. Like so many things that I only have to do it once in a while, I couldn’t remember how to do it. So this blog post is something to remind me in the future should I need to do it agian.

Here is one way to do it, thanks to this Stack Overflow question. (Alternatively, check man nmcli and man nmcli-examples which have detailed information):

nmcli con add type wifi con-name <connect name> ifname wlan0 ssid <ssid>
nmcli con modify <connect name> wifi-sec.key-mgmt wpa-psk
nmcli con modify <connect name> wifi-sec.psk <password>
nmcli con up <connect name>

Here’s an example to connect to a hidden wifi called CanaBleu using wifi interface wlp59s0.

# nmcli con add type wifi con-name CanaBleu ifname wlp590 CanaBleu
# nmcli con mod CanaBleu wifi-sec.key-mgmt wpa-psk
# nmcli con mod CanaBleu wifi-sec.psk MYSECRETPASSWORD
# nmcli con up CanaBleu