-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"wifi-password ERROR: Could not retrieve current SSID. Are you connected?" #34
Comments
Same situation |
The app doesn't work since Ventura, I think? Something to do with root privileges |
This script relies on the Here is a modified bare bones script that gets the current SSID's password via #!/usr/bin/env zsh
# Original script by rauchg/wifi-password.
# Ventura/Sonoma deprecated the macos "airport CLI".
# Patched by haakonstorm to use networksetup instead
echo Enter admin pwd when prompted by macos dialog.
ssid=`networksetup -getairportnetwork en0 | awk -F": " '{print $2}'`
echo SSID: "$ssid"
pwd="`security find-generic-password -ga \"$ssid\" 2>&1 >/dev/null`"
pwd=$(echo "$pwd" | sed -e "s/^.*\"\(.*\)\".*$/\1/")
echo password:
echo "\033[96m$pwd\033[39m" |
That's a good start @haakonstorm, but the WiFi interface won't always be Here's a different approach that I've been using: #!/usr/bin/env bash
if [[ -n $1 ]]; then
SSID=$1
else
WIFI_IF=$(scutil <<< "list" | grep -m1 'AirPort' | awk -F/ '{print $(NF-1)}')
SSID=$(networksetup -getairportnetwork "${WIFI_IF}" | sed -En 's/Current Wi-Fi Network: (.*)$/\1/p')
[[ -n $SSID ]] || { echo 1>&2 "error retrieving current SSID. are you connected?"; exit 1; }
fi
echo -e "\033[90m … getting password for \"${SSID}\". \033[39m"
echo -e "\033[90m … keychain prompt incoming. \033[39m"
SECOUT=$(security find-generic-password -ga "${SSID}" 2>&1 >/dev/null)
(( $? == 128 )) && { echo "user cancelled"; exit 0; }
PASS=$(sed -En 's/^password: "(.*)"$/\1/p' <<<"$SECOUT")
[[ -n $PASS ]] || { echo 1>&2 "password for \"${SSID}\" not found in Keychain"; exit 1; }
echo -e "\033[96m ✓ ${PASS} \033[39m" |
Any updates or ETA for a fix on this? |
Nope |
I just took the script above and put where I keep my executable scripts and gave it permission to run. I could tell you how to do all that, but its best that you learn for yourself :) I named mine "wifi" |
Getting the error message "ERROR: Could not retrieve current SSID. Are you connected?" if I try to use wifi-password
Manually specifying the SSID works, it just can't detect my current Wifi connection. Help?
I'm on MacOS Sonoma 14.4, M1 macbook pro
The text was updated successfully, but these errors were encountered: