Skip to content

Instantly share code, notes, and snippets.

@Pierozi
Created September 12, 2016 10:35
Show Gist options
  • Save Pierozi/370fe35a075494ed2cc7946b1411bb3e to your computer and use it in GitHub Desktop.
Save Pierozi/370fe35a075494ed2cc7946b1411bb3e to your computer and use it in GitHub Desktop.
Show the current password of wifi ssid connected | under Ubuntu / Debian based system
#!/bin/sh
myWifiPassword() {
SSID=`iwgetid -r`
FILE=/etc/NetworkManager/system-connections/$SSID
if [ ! -f "$FILE" ];
then
FILE="/etc/NetworkManager/system-connections/Auto $SSID"
fi
sudo cat "$FILE" | sed -rn '/psk=([0-9A-Za-z]+)/p' | awk '{print substr($1,5)}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment