Skip to content

Instantly share code, notes, and snippets.

@aloisdg
Created July 20, 2022 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aloisdg/9caf881e7cde9058826f767aa1ba1d24 to your computer and use it in GitHub Desktop.
Save aloisdg/9caf881e7cde9058826f767aa1ba1d24 to your computer and use it in GitHub Desktop.
A small utility to print the password to the current or a given ssid
#!/bin/bash
ssid=""
if [ $# -eq 0 ] || [ -z "$1" ]
then
current=$(iwgetid -r)
ssid="${current}.nmconnection"
else
ssid=$(sudo ls /etc/NetworkManager/system-connections/ | grep "$1")
fi
path="/etc/NetworkManager/system-connections/${ssid}"
pskLine=$(sudo grep -r '^psk=' "$path")
psk=${pskLine:4}
echo "$psk"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment