WiFi Password Command-Line Cheatsheet
Every major operating system keeps saved WiFi passwords in a local credential store that is readable from the command line, given the right privileges. This page is a copy-paste reference for revealing one password, listing every saved network, and exporting all credentials in bulk on Windows 10/11, macOS (Intel and Apple Silicon), Ubuntu, Fedora, Arch, and any other Linux running NetworkManager or iwd. Every command below is tested, ready to paste, and kept minimal: no third-party tools, no downloads, no cloud.
Quick reference table
| OS | One-shot command | Admin? |
|---|---|---|
| Windows 10 / 11 | netsh wlan show profile name="SSID" key=clear | Yes |
| macOS | security find-generic-password -ga "SSID" | Sometimes |
| Linux (NetworkManager) | sudo nmcli -s -g 802-11-wireless-security.psk c show "SSID" | Yes |
| Linux (any) | sudo grep -H psk= /etc/NetworkManager/system-connections/* | Yes |
| Linux (iwd) | sudo grep -H Passphrase /var/lib/iwd/*.psk | Yes |
Windows: netsh wlan
The netsh binary has shipped with every Windows since XP and exposes the full WiFi credential store. All three commands below assume an elevated PowerShell or Command Prompt (right-click Start, choose Terminal (Admin)).
List every saved WiFi profile:
netsh wlan show profilesShow the plain-text password for one profile:
netsh wlan show profile name="MyHomeWiFi" key=clearThe WPA key is on the Key Content line inside the Security settings block. If that line is missing, you either forgot key=clear or you are not running elevated.
Dump every password in one table (PowerShell):
$profiles = netsh wlan show profiles | Select-String "All User Profile\s+:\s+(.+)quot; | ForEach-Object { $_.Matches.Groups[1].Value.Trim() }
$rows = foreach ($name in $profiles) {
$raw = netsh wlan show profile name="$name" key=clear
$pw = ($raw | Select-String "Key Content\s+:\s+(.+)quot;).Matches.Groups[1].Value
[PSCustomObject]@{ SSID = $name; Password = $pw }
}
$rows | Format-Table -AutoSizeThe output is a clean two-column table. Pipe it to | Export-Csv wifi.csv -NoTypeInformation to save, and remember to delete the CSV afterwards. See the Windows 11 walkthrough for a GUI alternative.
Export every profile as XML with plain key:
mkdir C:\WiFiBackup
netsh wlan export profile key=clear folder=C:\WiFiBackupUseful for migrating every network to a new PC at once. Each XML file contains the SSID, security type, and plain WPA key in the keyMaterial element.
macOS: security
The security binary is the Terminal interface to Keychain on macOS. Works identically on Intel, M1, M2, and M3 Macs.
Reveal one password:
security find-generic-password -ga "MyHomeWiFi"The password line appears on stderr as password: "…". The first invocation for a given SSID triggers a Keychain confirmation dialog where you authenticate with Touch ID or your login password.
Return only the password (suitable for pipelines):
security find-generic-password -wa "MyHomeWiFi"List every saved WiFi profile:
networksetup -listpreferredwirelessnetworks en0Dump every password in one table:
IFACE=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}')
for ssid in $(networksetup -listpreferredwirelessnetworks "$IFACE" | tail -n +2 | sed 's/^[[:space:]]*//'); do
pw=$(security find-generic-password -wa "$ssid" 2>/dev/null)
[ -n "$pw" ] && printf "%-30s %s\n" "$ssid" "$pw"
doneReplace en0 with en1 on Macs where WiFi is the second adapter. For a full macOS walkthrough with the Keychain Access GUI see the Mac Keychain article.
Linux: NetworkManager (Ubuntu, Fedora, most desktops)
NetworkManager is the default WiFi stack on Ubuntu, Fedora Workstation, Debian GNOME, Pop!_OS, Linux Mint, and most other mainstream desktop distributions. Credentials live in /etc/NetworkManager/system-connections/ as INI-style .nmconnection files owned by root.
List saved connections:
nmcli connection showReveal one password (no sudo needed on many distros):
nmcli --show-secrets connection show "MyHomeWiFi" | grep 802-11-wireless-security.pskOr just the password, scriptable:
sudo nmcli -s -g 802-11-wireless-security.psk connection show "MyHomeWiFi"Grep every .nmconnection at once:
sudo grep -H '^psk=' /etc/NetworkManager/system-connections/*.nmconnection | sed 's|.*/||; s|.nmconnection:psk=| |'The result is a two-column SSID / password listing. On modern distributions the .nmconnection files are chmod 600 root:root, which is why the commands need sudo.
List available networks with signal strength:
nmcli device wifi listLinux: iwd (Arch, embedded, some laptops)
Arch, some embedded distributions, and Intel-based ChromeOS derivatives use iwd instead of NetworkManager. Credentials are stored in /var/lib/iwd/SSID.psk, one INI file per network.
sudo ls /var/lib/iwd/
sudo cat /var/lib/iwd/MyHomeWiFi.pskThe Passphrase= line is the plain WPA key. Some versions of iwd replace it with PreSharedKey=, which is the PMK in hex rather than the passphrase. A hex PMK is not reversible to the original passphrase without cracking.
Bulk export from iwd:
sudo grep -H Passphrase /var/lib/iwd/*.psk | sed 's|/var/lib/iwd/||; s|.psk:Passphrase=| |'Linux: wpa_supplicant (servers, OpenWrt)
Headless servers and OpenWrt routers often use raw wpa_supplicant, with configuration in /etc/wpa_supplicant/wpa_supplicant.conf.
sudo grep -E 'ssid=|psk=' /etc/wpa_supplicant/wpa_supplicant.confPSK values may be stored as plain strings in quotes or as a 64-character hex PMK. Quoted strings are the plain passphrase; bare hex is a derived key and cannot be reversed.
Listing nearby networks (not saved, just visible)
Sometimes you need to scan for SSIDs and strengths rather than reveal saved ones. The command differs per OS but the intent is the same:
# Windows
netsh wlan show networks mode=bssid
# macOS (deprecated in Sonoma, but still shipped)
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s
# Linux NetworkManager
nmcli device wifi list
# Linux raw
sudo iw dev wlan0 scan | grep SSIDOperational tips
- Redirect to a file with restrictive permissions rather than letting passwords scroll in your terminal. Example:
... > wifi.txt && chmod 600 wifi.txt. - Clear shell history after bulk dumps. Bash:
history -c. Zsh:history -p. PowerShell:Clear-History; Remove-Item (Get-PSReadlineOption).HistorySavePath. - Never scp a Keychain file to another machine. The wrap key is tied to the device; the copy cannot be decrypted elsewhere.
- Screen-share caution: if your terminal is being recorded or mirrored, pipe the password to
pbcopy(mac),Set-Clipboard(Windows), orxclip -sel c(Linux) instead of printing it to stdout.
How each OS actually stores the key
Understanding where the password lives on disk helps when the standard command fails. On Windows, WiFi profiles are XML files under C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces\{GUID}\, with the key encrypted by DPAPI scoped to the Local System account. Only an elevated process can decrypt it, which is why key=clear needs admin rights. Copying the XML files to another machine does not help because DPAPI keys are tied to the local SID and machine.
On macOS, both login.keychain-db and System.keychain are SQLite databases under ~/Library/Keychains/ and /Library/Keychains/. The wrap key lives in the Secure Enclave on Apple Silicon and the T2 chip on later Intel Macs, which is why the raw SQLite file is unreadable if moved.
On Linux with NetworkManager, files in /etc/NetworkManager/system-connections/ are plain INI text with chmod 600. No encryption at rest. This is simpler but more exposed: anyone with root or physical access to the disk can read every WiFi password instantly. Encrypting the root filesystem (LUKS, dm-crypt) is the standard mitigation.
iwd uses a similar approach in /var/lib/iwd/. wpa_supplicant on servers and OpenWrt is plain text too. Chrome OS uses its own shill daemon with per-user encryption tied to the Google account cryptohome.
Bulk migration: moving every WiFi profile to a new device
A common reason to reach for these commands is to migrate all saved networks to a new machine before wiping the old one. The workflow depends on the source and destination OS:
Windows to Windows:
# On old PC (elevated)
netsh wlan export profile key=clear folder=C:\WiFiBackup
# On new PC (elevated), after copying the folder
Get-ChildItem C:\WiFiBackup\*.xml | ForEach-Object { netsh wlan add profile filename="$($_.FullName)" }macOS to macOS:
Skip manual export entirely. Sign into the new Mac with the same Apple ID, enable iCloud Keychain, and all WiFi profiles sync within a few minutes. For a non-Apple-ID route, Migration Assistant copies Keychain intact.
Linux to Linux:
# On old box
sudo tar czf nm.tgz -C /etc/NetworkManager system-connections
# On new box
sudo tar xzf nm.tgz -C /etc/NetworkManager
sudo chmod 600 /etc/NetworkManager/system-connections/*
sudo systemctl restart NetworkManagerCross-OS migration (Windows to Linux, etc.) is not directly supported. The practical path is to export every password as plain text on the source, paste them into the target's network list one by one, and securely wipe the intermediate file with shred -u (Linux), rm -P (macOS), or cipher /w:C:\\ (Windows).
Scripted password audit
Once you can dump every saved WiFi password to a file, the next step is often an audit: which networks still use a weak password that would crack in minutes under WPA2? This is useful on family laptops where an old memorable password was reused for years. The script below works on Linux and macOS; it reads a password dump and prints anything shorter than 12 characters or appearing in the rockyou top-1000 list.
#!/usr/bin/env bash
# Usage: ./audit.sh wifi-dump.txt
# Format: each line = SSID<tab>password
curl -s https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10k-most-common.txt \
| head -1000 > /tmp/top1k.txt
while IFS=#x27;\t' read -r ssid pw; do
flags=""
[ ${#pw} -lt 12 ] && flags="${flags}[SHORT] "
grep -qx "$pw" /tmp/top1k.txt && flags="${flags}[COMMON] "
[ -n "$flags" ] && printf "%-30s %s %s\n" "$ssid" "$flags" "$pw"
done < "$1"The audit is pessimistic by design: any password under 12 characters is flagged even if it is random. For a fuller picture of what makes a passphrase resistant to offline attacks, see the WPA3 vs WPA2 deep dive.
Frequently asked questions
Why does netsh say the profile does not exist when I can see the SSID in the tray?
netsh is case sensitive and trims no whitespace. Copy the SSID byte-for-byte from the netsh wlan show profiles output, including any trailing spaces.
Why does security on macOS output an extra line like Cannot open keychain?
macOS searches both the login and System keychains. Cannot open the System keychain is normal for a non-admin user; the command still returns the password from the login keychain.
What if nmcli returns empty for psk even though the network connects?
The password was saved with system-only readability and your user is not in the netdev or wheel group. Prepend sudo or become root temporarily.
Are any of these commands available in recovery mode / WinPE?
netsh is on WinPE by default. security is not on macOS Recovery because Keychain is locked. On Linux live USBs, NetworkManager and iwd both work if the root filesystem is mounted and chrooted.
Do these commands reveal enterprise 802.1X credentials?
Not usably. Enterprise identities are stored as encrypted blobs and client certificates that cannot be exported as plain strings. Only WPA-PSK networks yield a plain key.
How do I do the same on Chrome OS?
Chrome OS uses shill, not NetworkManager. Enter developer mode, then run sudo cat /var/lib/shill/shill.profile and look for Passphrase lines. This voids some device warranties; do it only on personal Chromebooks.
No saved credential anywhere?
If no device on the LAN has the password saved, check the router admin panel or use the authorized handshake recovery form.
Authorized machines only
Every command above requires local admin on the device. Use only on systems you own or manage under written authorization.
Related reading
GUI walkthroughs: Windows 11, Mac Keychain, iPhone, Android. Background on WPA itself: WPA handshake primer.