Connect to Wi-Fi from the terminal with `nmcli`

On a server or over SSH there is no GUI — NetworkManager's nmcli can scan, connect and save Wi-Fi profiles entirely from the command line.

LinuxnmcliWi-FiclinetworkmanagerLow risk
Run `nmcli device wifi connect "SSID" password "password"` to join a network, and `nmcli device wifi list` beforehand to see available networks.

01Command

Command
$ nmcli device wifi connect "MySSID" password "MyPassword"

02What it does

The one-liner scans, connects and stores the credentials as a NetworkManager connection profile, so the machine reconnects automatically after a reboot. `nmcli device wifi rescan` refreshes the list if the network just appeared, and `nmcli connection show` lists saved profiles. Related but forgotten: `nmcli connection up <name>` reconnects an existing profile and `nmcli radio wifi on` re-enables a disabled radio.

03Risk

RiskLow risk
RequirementsRequires NetworkManager with nmcli (default on Fedora, Ubuntu desktop and most distros); wifi radio must be enabled (`nmcli radio wifi on`)
!Warning: The password is stored unencrypted in /etc/NetworkManager/system-connections/ (root-only readable) unless the connection is marked user-private.

04Undo

Undo
$ nmcli connection delete "MySSID"

05Sources

Last verified: 2026-09-17 · Category: Network