Created
October 21, 2017 12:03
-
-
Save tiwiz/a54b9071c7da5118d6dc3f70d60b7e60 to your computer and use it in GitHub Desktop.
This Gist contains the way to get current wifi SSID and Password from a Mac OS X terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage ./password Name_Of_The_Wi-Fi_Network | |
# This script returns the password of the wireless SSID in input | |
echo "Wi-Fi SSID: $1" | |
ESCAPED=$(echo $1 | sed "s/'/\\\'/g" | sed "s/[ ]/\\\\ /g") | |
sudo security find-generic-password -ga ${ESCAPED} | sed -n -e 's/^.password: //p' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This line returns the current SSID to which we are connected to | |
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -n -e 's/^.[ \t]*SSID: //p' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment