As you may already know, when you connect to a wireless network for the first time, the password will be saved in your Linux machine. So you don't need to enter the password of your wireless network every time. In the subsequent times, the available WiFi networks will be automatically connected. Over the time, you might have forgotten the password. Now you want to add a new device to same WiFi network, but you don't remember the password. What you are going to do? No worries! I know a few ways to find WiFi password of connected networks in Linux.
Find WiFi Password Of Connected Networks In Linux
We can find the Wi-Fi password of the saved networks either from Command line or GUI or using any third-party password recovery tools. The following steps were tested in Ubuntu 20.04 LTS desktop (GNOME), however these steps are probably same on other Linux distributions.
Let us first see how to reveal a wireless network password from command line.
1. Find WiFi Password Of Connected Networks From Command line
In Ubuntu and its variants, the wireless network configuration files are saved in the /etc/NetworkManager/system-connections/ directory. Let us take a look at the saved or connected WiFi network config files:
$ ls /etc/NetworkManager/system-connections/
Sample output:
'HP 7 VoiceTab Network' JioFi4_12E9FE sktab
As you see, I have config files of 3 saved networks in my Ubuntu system. These files will have various details of each network, such as wifi id, mac address, SSID, authentication method, wifi password etc. Just open this file using cat command or text editors to view the password.
For instance, I am going to view the details of "JioFi4_12E9FE" WiFi using command:
[...] [wifi] mac-address=XX:XX:XX:XX:XX:XX mac-address-blacklist= mode=infrastructure ssid=JioFi4_12E9FE [wifi-security] auth-alg=open key-mgmt=wpa-psk psk=xxxxxxxxxxx [ipv4] dns-search= method=auto [ipv6] addr-gen-mode=stable-privacy dns-search= method=auto
In the above output, the psk value is the password of the given Wifi network. For those wondering, PSK (Pre-Shared Key) is a client authentication method. It uses a string of 64 hexadecimal digits, or as a passphrase of 8 to 63 printable ASCII characters, to generate unique encryption keys for each wireless client. PSK is one of two available authentication methods used for WPA and WPA2 encryption on Juniper Networks wireless networks.
Alternatively, you can use grep command to quickly find the password of saved or connected WiFi networks like below:
$ sudo grep -r '^psk=' /etc/NetworkManager/system-connections/
This command will display the psk (password) of all connected Wireless networks.
Sample output:
/etc/NetworkManager/system-connections/sktab:psk=xxxxxxxx /etc/NetworkManager/system-connections/JioFi4_12E9FE:psk=xxxxxxxx
You can also use:
$ sudo grep psk= /etc/NetworkManager/system-connections/*
If you don't want to see the WiFi SSID names, but only the passwords, use -h flag:
$ sudo grep -hr '^psk=' /etc/NetworkManager/system-connections/
Sample output:
psk=xxxxxxxx psk=xxxxxxxx
One problem of the above command is you don't know which password is for which SSID. So, it is better not to use -h flag.
2. Find WiFi Password Of Connected Networks From Commandline Using Nmcli
Instead of looking into configuration files, we can use nmtui, a curses interface for NetworkManager.
Find the list of available wired and wireless network connections using command:
$ nmcli -g NAME connection show
Sample output:
JioFi4_12E9FE mpqemubr0 tap-d8f1eebb39f HP 7 VoiceTab Network sktab Wired connection 1
Now find the password of a wifi network, for example "JioFi4_12E9FE", like below:
$ nmcli -s -g 802-11-wireless-security.psk connection show JioFi4_12E9FE
To get all details of the given network, simply remove the option "-g 802-11-wireless-security.psk" from the above command:
$ nmcli -s connection show JioFi4_12E9FE
Thanks Stephane for this tip.
3. Find WiFi Password Of Connected Networks From Network Manager (GUI)
If you are not comfortable with command line way, here is how to do it graphically.
Click on the WiFi icon on the top panel. A drop-down menu will appear. Click on the connected WiFi SSID and again click "WiFi Settings".
In the next window, you will see a list of currently connected networks. Click on the gear icon next to your preferred wifi network.
Now the selected WiFi network settings window will open. Under the "Security" tab, you will see the password in asterisks. To reveal the password, simply click "Show password" check box.
4. Find WiFi Password Of Connected Networks Using Wifresti
Wifresti is a simple Python script to find the password of saved or connected WiFi networks. It works on Linux, Mac OS and Windows. This script is created by the same developer who created "Katoolin".
Install Wifresti In Linux
Git clone the Wifresti GitHub repository using command:
$ git clone https://github.com/LionSec/wifresti.git
This command will download the contents of Wifresti repository in a local folder named "wifresti".
Cd into this directory:
$ cd wifresti/
Copy the wifresti.py to your $PATH:
$ sudo cp wifresti/wifresti.py /usr/bin/wifresti
Make it executable:
$ chmod +x /usr/bin/wifresti
Next, run wifresti as sudo user to list all available WiFi networks:
$ sudo wifresti
Choose the operating system you use:
/$$ /$$$$$$ /$$ /$$
|__/ /$$__ $$ | $$ |__/
/$$ /$$ /$$ /$$| $$ \__//$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$
| $$ | $$ | $$| $$| $$$$ /$$__ $$ /$$__ $$ /$$_____/|_ $$_/ | $$
| $$ | $$ | $$| $$| $$_/ | $$ \__/| $$$$$$$$| $$$$$$ | $$ | $$
| $$ | $$ | $$| $$| $$ | $$ | $$_____/ \____ $$ | $$ /$$| $$
| $$$$$/$$$$/| $$| $$ | $$ | $$$$$$$ /$$$$$$$/ | $$$$/| $$
\_____/\___/ |__/|__/ |__/ \_______/|_______/ \___/ |__/
Author: LionSec | Website: www.neodrix.com | @lionsec1 V1.0
Please choose your operating system.
1) linux
2) Windows
3) Mac OS
> 1
[...]
You will see the list of available Wifi networks. Enter the network name to view its password. To view all WiFi networks' password, type "a" and hit ENTER.
[...] All wireless networks : HP 7 VoiceTab Network JioFi4_12E9FE sktab Insert the network name , or press (a) to see information about all networks. > JioFi4_12E9FE ###################################### - JioFi4_12E9FE - ###################################### key-mgmt=wpa-psk psk=xxxxxxxx ############################################################################################# [...]
To quit, press CTRL+C.
Also, there are many password recovery tools available in Kali Linux. You don't have to install Kali Linux. Just install the Kali Linux tools on your Ubuntu system and use the password recovery tools of your choice. To know how to install Kali Linux tools on Ubuntu, refer the following guide.
Related read:
- How To Update Wifi Network Password From Terminal In Arch Linux
- How To Monitor WiFi Connection From Command Line In Linux
Hope this helps.
Featured
.Resource:
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Reddit | Facebook | Twitter | LinkedIn | RSS feeds
Have a Good day!!
4 comments
wifiresti is written in Python 2 which is now obsolete and no longer officially supported.
Somebody needs to update and convert it to Python 3.
There is also a curses interface for NetworkManager called nmtui.
And of course, instead of looking directly into the config files (as root), one can use nmcli
(bash) nmcli -g NAME connection show
HP 7 VoiceTab Network
JioFi4_12E9FE
sktab
To obtain the password for JioFi4_12E9FE do
(bash) nmcli -s -g 802-11-wireless-security.psk connection show JioFi4_12E9FE
xxxxxxxxxxx
And to get all values, remove the option -g 802-11-wireless-security.psk
Thanks for the suggestion. I will add your inputs in the article.
seems to be applicable to Mint and Fedora, but not on Raspbian which does not have an /etc/NetworkManager directory.