I am at my school and the computer I am currently using is connected to a Wi-Fi network. I want to know the Wi-Fi password and I am on a Mac. I know there is a way to do it through Terminal.

What I am using is:

security find-generic-password -ga  AirPort

I use that to find the password if it is in a keychain, but I know there is another way to do it. My friend who is a coder told me their is but they said they wont help me. All they told me was "generic" was a hint. I used "generic" in my command but I don't get it.

I tried your answer but it keeps asking my for the admin password. I am connected to the wifi but it still wont work. My coding friend looked at this and said I'm not looking for a AirPort password I'm looking for a regular password.

  • 1
    Prerequisite, you are the owner, with Admin password, you are or have been connected to the specific WiFi and the password is saved in keychain.
    – Ruskes
    Commented Mar 10, 2015 at 16:35

5 Answers 5

security find-generic-password -D "AirPort network password" -a $SSID -g | grep "password:"

Replace $SSID with the SSID (the network name) of the network that you wish to obtain the key of.
This command looks for all keys with a type of "AirPort network password" and searches for the key with the name of the SSID that you provide.

  • I've added following two functions wssid and wpass in my ~/.zshrc to detect current SSID and get the password for it. No need to set the $SSID variable. Also use the -w parameter instead of -g to show just the password. No need to grep it then... wssid () { /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F' SSID: ' '/ SSID: / {print $2}' ; } wpass () { security find-generic-password -D 'AirPort network password' -a $(wssid) -w ; } Sorry, can't add answer. Low reputation yet. Upvote would help ;)
    – kub1x
    Commented Feb 17, 2021 at 9:59

I think what you're actually looking for is this:

security find-generic-password -ga "ROUTERNAME" | grep "password:"

You'll get in response something like:

password: "ThePassword"

You can also use the flag -w to show only the raw password and avoid any extra grep, like so:

security find-generic-password -wga "ROUTERNAME"

Which in the above example would simply return:


Hope this helps!

  • Thanks, I have the MacBook connected to the WiFi but forget the password. help me a lot to retrieve the password and use the internet on the mobile.
    – Arefe
    Commented Aug 24, 2019 at 14:20
  1. get the SSID of current wireless network (use --getinfo)

    /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I
         agrCtlRSSI: -51
         agrExtRSSI: 0
        agrCtlNoise: -93
        agrExtNoise: 0
              state: running
            op mode: station 
         lastTxRate: 130
            maxRate: 217
    lastAssocStatus: 0
        802.11 auth: open
          link auth: wpa2-psk
              BSSID: 0:31:c2:41:53:14
               SSID: DansLeVille
                MCS: 15
            channel: 5

    But if you want to get all wifis in your area, (use --scan)

    /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s
                                SSID BSSID             RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
                      America_Online 00:71:c2:9a:11:b0 -86  1       Y  US WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP) 
                         xfinitywifi 00:71:c2:9a:11:b2 -72  1       Y  US NONE
                         xfinitywifi 84:00:2d:78:ee:ea -56  11      Y  US NONE
                               amber 74:1b:b2:d5:93:a9 -53  104     Y  US WPA2(PSK/AES/AES) 
                         xfinitywifi 74:85:2a:a9:f3:4a -66  11      Y  US NONE
                       HOME-1A17-2.4 74:85:2a:a9:f3:48 -66  11      Y  US WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP) 
              Cooper Works Streaming 90:a7:c1:b9:6c:37 -50  11,-1   Y  -- WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP) 
                               amber 74:1b:b2:d5:93:a8 -49  11      Y  US WPA2(PSK/AES/AES) 
    1. get the password for wireless

      sudo security find-generic-password -D "AirPort network password" -a YOUR_SSID_NAME -g | grep password:
      password: "pseudononymous1234!!!"

    You see the password: at the end.

  • 2
    This is the same command I answered with over a year prior…?
    – grg
    Commented Apr 29, 2016 at 6:08
  • when I type this command, I get exactly same output as shown BUT without password at the bottom. Do you know why?
    – tera_789
    Commented Dec 20, 2017 at 3:09
  • @NS_777 is the wireless public network? Commented Dec 20, 2017 at 3:17
  • @prayagupd it is university library. can only be accessed if you are a student. each student has different username and password to access it
    – tera_789
    Commented Dec 20, 2017 at 4:26

I'm not sure what version of OS X the other answer or original question is for but it's not accurate on 10.10 Mavericks. You need this:

security find-generic-password -D "802.1X Password"

Maybe networks using actual Apple AirPort hardware are saved in the keychain Differently?

  • This shows passwords for networks using a different kind of authentication.
    – grg
    Commented Dec 13, 2020 at 21:23

This will display the SSID, password, and a QR code for your current WiFi network.

Example QR Code

Use this script to retrieve the current network's SSID, password, and generate a QR code for easy mobile access:


# Get the current SSID
SSID=$(networksetup -getairportnetwork en0 | awk -F': ' '{print $2}')

# Retrieve the password
PASSWORD=$(security find-generic-password -D "AirPort network password" -wa "$SSID")

# Retrieve the security type
SECURITY=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk -F': ' '/^ *Security/ {print $2}')

# Adjust the security type for the QR code
case "$SECURITY" in
  "WPA2 Personal") SECURITY="WPA";;
  "None") SECURITY="nopass";;

# Output network information
echo "SSID: $SSID"
echo "Password: $PASSWORD"
echo "Security: $SECURITY"

# Generate QR code for WiFi access

Please note that executing this script will require your user password for retrieving the WiFi password.

Save this script as showpass and make it executable with the command:

chmod +x showpass

Before running this script, ensure qrencode is installed. If not, install it using Homebrew:

brew install qrencode

Now you can run the script with:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .