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.
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
!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
- nmcli(1) — command-line tool for controlling NetworkManagerEvidence: Documents `nmcli device wifi connect <SSID> password <pass>` and `nmcli device wifi list` for scanning
Last verified: 2026-09-17 · Category: Network