Skip to content

Instantly share code, notes, and snippets.

@codycodes
Last active November 24, 2020 11:54
Show Gist options
  • Save codycodes/517955946fea3925bde6c5c9a2b63f88 to your computer and use it in GitHub Desktop.
Save codycodes/517955946fea3925bde6c5c9a2b63f88 to your computer and use it in GitHub Desktop.
Two commands to get your current WiFi password or any WiFi password stored in your macOS keychain!
#!/bin/bash
get_current_wifi_password() {
# this command from http://bit.ly/2zWtUhQ
current_wifi=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | \
awk '/ SSID/ {print substr($0, index($0, $2))}'`
security find-generic-password -a "$current_wifi" -g | tail -0
}
get_wifi_password() {
security find-generic-password -a "$1" -g | tail -0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment