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. – Buscar웃 Mar 10 '15 at 16:35
security find-generic-password -D "AirPort network password" -a SSID -g

Replace SSID with the SSID 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 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:

ThePassword

Hope this helps!

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?

  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.

  • 1
    This is the same command I answered with over a year prior…? – grg Apr 29 '16 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 Dec 20 '17 at 3:09
  • @NS_777 is the wireless public network? – prayagupd Dec 20 '17 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 Dec 20 '17 at 4:26

protected by user3439894 Dec 20 '17 at 3:20

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.