As you may already know, when you connect to a wireless network for the first time, the WiFi password is 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 network will be automatically connected. Over the time, you might have forgotten the WiFi password. One day you want to add a new device to the same WiFi network, but you don't remember the password. What are you going to do? No worries! I know a few ways to find WiFi password of connected networks in Linux.
Table of Contents
Find WiFi Password Of Connected Networks In Linux
We can get 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), and Debian 11 Cinnamon editions. However, these steps are almost same for other Linux distributions.
Let us first see how to reveal a wireless network password from the command line.
1. View Saved 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 cat
command:
$ sudo cat /etc/NetworkManager/system-connections/JioFi4_12E9FE
Sample output:
[...] [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 (i.e. JioFi4_12E9FE
).
? 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. Show Saved WiFi Password using Nmcli
Instead of looking into configuration files, we can use nmcli
, a command-line tool for controlling NetworkManager.
First, let us find the list of available wireless network connections using the following command:
$ nmcli device wifi list
Sample output from my Debian 11 system
IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY xx:xx:xx:xx:xx:49 Ostechnix_jio_4g Infra 6 130 Mbit/s 100 ▂▄▆█ WPA2 * xx:xx:xx:xx:xx:4A Ostechnix_jio_5g Infra 149 270 Mbit/s 94 ▂▄▆█ WPA2 xx:xx:xx:xx:xx:69 Wifi network1 Infra 11 130 Mbit/s 44 ▂▄__ WPA2 xx:xx:xx:xx:xx:6A WiFi network2 Infra 36 270 Mbit/s 44 ▂▄__ WPA2 xx:xx:xx:xx:xx:44 HP-Print-44-LaserJet Pro MFP Infra 2 65 Mbit/s 27 ▂___ WPA1 WPA2
As shown in the above output, you will get the following details:
- BSSID address (MAC physical address of the access point or wireless router),
- SSID name,
- Mode,
- Channel,
- Connection speed,
- Signal strength,
- and Wireless Security protocol (E.g. WPA2)
The currently connected WiFi network is marked with an Asterisk (*). As per the above output, the currently connected WiFi network is Ostechnix_Jio_5g.
Heads Up: Please note that the nmcli
commands can be shortened, so nmcli d w l
command will also display the list of WiFi networks.
Now, let us display the get the password of the currently connected WiFi network using command:
$ nmcli device wifi show-password
Sample output:
SSID: Ostechnix_jio_5g Security: WPA Password: xxxxxxxxxxxx █████████████████████████████████ ██ ▄▄▄▄▄ █▄▄██████▄▄▀█ █ ▄▄▄▄▄ ██ ██ █ █ █ ▀█ ▄ ▀█▀▄ ▀█ █ █ ██ ██ █▄▄▄█ █▄ ▄▄▀▄▄▄▄▀█ ▀█ █▄▄▄█ ██ ██▄▄▄▄▄▄▄█▄▀▄▀▄█ ▀ ▀▄█ █▄▄▄▄▄▄▄██ ██▄▄ ▀▀▄▀ ▀████▄▄ ▀▀▄▀█ ▄ ▀▄██ ██ ▄ █▀ ▄▄▀██▀▀ ▀▀▄▀█ █▄█▄ ▄▄███ ██▀▄█ ▄▄▄ █▄▀ ██ ▄█ ███▄▄▄▄████ ███▀▄ ▄▄▄▀▀█▄█ ▄█▀▀▄▄▄█▄▀▄▄ ▄▄▄██ ████ ▀▄▄▄ ▀▄▄▀ ██ ▄ ██▄▄▄█ ██ ██▄█▄▀██▄█▀ ▀▄ ██ █ ▀▀ ▀ ▄█▀▀▀██ ███▄█▄▄▄▄█▀ █▄ ▀▀▄█▄█▄ ▄▄▄ █ ▄▄██ ██ ▄▄▄▄▄ ██ ▀▄▄ █▀▄ ▄ █▄█ ██ ███ ██ █ █ █▀▀ ▀ █▄ █▀ ▄ ▄ ▀▄ ██ ██ █▄▄▄█ █ █ ██▀██▄▄█▀▄█▄▀▀▄▀▄██ ██▄▄▄▄▄▄▄█▄▄▄███▄▄▄██▄▄██▄█▄▄▄███ █████████████████████████████████
The above command will only get the WiFi network details. If you want to show both wired and wireless connections, use the following command variants as well.
$ nmcli -g NAME connection show
Sample output from my Ubuntu 20.04 system:
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
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 in Ubuntu GNOME.
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 uncheck "Show password" check box.
On Debian Cinnamon:
Click the WiFi Network icon and choose "Network Settings" from the taskbar.
Click the gear button next to the connected WiFi network.
Under the "Security" tab, uncheck the "Show password" checkbox to view the password.
On KDE systems:
If you're using KDE, the network connections pop-up has a button for it:
4. Get Saved 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.
Conclusion
These are a few ways to find the saved password of a WiFi networks in Linux. Please note that these methods will help only to find the password of the connected WiFi networks. The won't help you to crack a WiFi password.
If you want to crack a WiFi, 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.
Resource:
Featured
.
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.