Skip to content

Instantly share code, notes, and snippets.

@tiwiz
Created October 21, 2017 12:03
Show Gist options
  • Save tiwiz/a54b9071c7da5118d6dc3f70d60b7e60 to your computer and use it in GitHub Desktop.
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
#!/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'
#!/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