Even if you are already connected to a network through Wi-Fi, you may still need it’s password for several reasons, such as if you want to connect another device to your wi-fi network or if you have forgotten the password. Fortunately, there are a number of ways to recover your password from your Mac OS X. In this guide we will list two methods that will come handy whenever you want to recover or view a lost or forgotten password.
However, for this method to work you must be connected to a wifi network.
Method 1: Through KeyChain Access
KeyChain Access stores passwords of the Wi-Fi networks and all other passwords saved on your Mac OS X including your mail, calendars, e-mails etc… Knowing your Wi-Fi’s password through this method is pretty much a matter of a few clicks.
Go to Applications > Utilities and click KeyChain Access. KeyChain Access window will open, showing a list of saved credentials.
In the left pane under KeyChain, click on login. For Yosemite, click on Local Items.
Click on the Kind header to sort the list by Kind, bringing Airport Network Passwords on top.
Under Name, locate and Double click on the Wi-Fi’s name whose password you want to know. If it’s the Wi-Fi network you are currently connected to, then click the Wi-Fi icon from the top right side of the menu to know its exact name. Once you open the Wi-Fi network’s window, check the box next to Show Password.
You will be asked to Enter your system’s password for authentication and then click Allow.
The password of the Wi-Fi network will be visible now. If not, the password was never stored on your Mac.
Method 2: Through Terminal
You can also use Terminal to know the connected Wi-Fi’s password. Go to Finder -> Applications > Utilities > Terminal.
In the terminal window type the following command and Press Enter.
security find-generic-password -ga “WIFI_NAME” | grep “password:”
Replace WIFI_NAME with the exact Wi-Fi’s name. If you don’t know the exact name of your WiFi then, Click on the Wi-Fi icon on the top right of the menu bar to see it’s name. After pressing Enter you will be prompted on the Terminal utility to type in your Mac OS X password, type it; you won’t see it being typed and hit enter.
The Wi-Fi’s password will be displayed now. If not, then it was not saved in the key chain.