Check Connected Wireless Password in Linux via Command Line

Posted on

Having connected in wireless connection to surf the internet may cause us to be unaware of the password given for wireless connection’s authentication.

While happily connected, some of our colleagues might ask for the same password to connect to the wireless connection. So, sometimes we don’t remember it or we do not have the luxury of time to just type the password in a notes or any place elsewhere.

That is when it is needed to find another way for retrieving the password for connecting the access point where our laptop or workstation has already been connected.

Below are alternative of steps can be done in Ubuntu Linux distribution operating system :

1. Check the connection file properties.

Actually all the previous connection which has already been successfully established has been saved in a file located in /etc/NetworkManager/system-connections. Using the command ‘ls -al’ can show all connection file property in the form of a list as shown below :

user@hostname:/etc/NetworkManager/system-connections$ ls -al
total 496
drwxr-xr-x 2 root root 4096 Nov 11 17:33 .
drwxr-xr-x 8 root root 4096 Jun 25 05:59 ..
-rw------- 1 root root  275 Mar 23  2016 XXX @XXX
-rw------- 1 root root  275 Mar 23  2016 XXX @XXX
-rw------- 1 root root  275 Mar 22  2016 XXX @XXX
-rw------- 1 root root  294 Oct  1  2015 XXX
-rw------- 1 root root  325 Nov  3  2015 XXXXXXXXX
-rw------- 1 root root  362 Mei 31 15:13 AndroidAP
-rw------- 1 root root  422 Aug 29 09:05 Andromax-XXX-XXXX
-rw------- 1 root root  435 Jun 30 08:08 Andromax-XXX-XXXX
-rw------- 1 root root  311 Sep  4  2015 Aston
-rw------- 1 root root  315 Nov  3  2015 XXXXXXX
-rw------- 1 root root  287 Jan 25  2016 xxxxxx-hotspot
-rw------- 1 root root  408 Nov 11 17:33 BOLT!-XXXX
-rw------- 1 root root  421 Jul 25 14:29 BOLT-XXXXX
-rw------- 1 root root  382 Mar 23  2016 BOLT! SUPER 4G-XXXX
-rw------- 1 root root  335 May 23  2015 BOLT!Super4G-XXXX
-rw------- 1 root root  279 Jan 18  2016 XXXXXXXXXX
-rw------- 1 root root  360 Feb  3  2016 xxxx_xxxx
-rw------- 1 root root 1021 Mar 18  2016 xxxx
-rw------- 1 root root  416 Sep 30 10:38 xxxx x
-rw------- 1 root root  285 Jun 10 13:30 XXXX XXXXXXX
-rw------- 1 root root  195 May  8  2015 XXXXXXX-X
-rw------- 1 root root  371 Jan 18  2016 xxxxx.xxx.xx
-rw------- 1 root root  294 Apr 15  2015 XXX
-rw------- 1 root root  212 Nov 24  2014 Galaxy S4 Network
-rw------- 1 root root  317 Sep  3  2015 xxxxxx
-rw------- 1 root root  326 Nov 20  2015 XXX XXXXXXXXX XX
-rw------- 1 root root  312 May  6  2015 Groovia@XXXXX
-rw------- 1 root root  205 Dec 17  2014 Guest
-rw------- 1 root root  275 May  3  2016 GUESTX-X
-rw------- 1 root root  314 Apr  6  2015 Guest-Hotspot
-rw------- 1 root root  225 Jun  7  2015 Galaxy S5 Network
-rw------- 1 root root  374 May 27 22:46 xxxxxxxxxxxx
-rw------- 1 root root  329 Nov 11  2015 xxxxxxxxxxxx
-rw------- 1 root root  223 Dec  3  2015 xxxxxxxxxxxx 1
-rw------- 1 root root  321 Dec  6  2015 xxxxxxxxxxxx 2
-rw------- 1 root root  321 Dec  6  2015 xxxxxxxxxxxx x-xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx
-rw------- 1 root root  321 Dec  6  2015 xxxxxxxxxxxx x-xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx
-rw------- 1 root root  321 Dec  6  2015 xxxxxxxxxxxx x-xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx
-rw------- 1 root root  321 Dec  6  2015 xxxxxxxxxxxx x-xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx
-rw------- 1 root root  321 Dec  6  2015 xxxxxxxxxxxx x-xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx
-rw------- 1 root root  321 Dec  6  2015 xxxxxxxxxxxx x-xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx
-rw------- 1 root root  330 Jul 26 16:12 hhonors
-rw------- 1 root root  344 Jul 26 16:14 hhonors-public
-rw------- 1 root root  316 Nov  2  2015 XXXXXXX
-rw------- 1 root root  283 Jun  1 10:26 XXXXXX XXXXXXXX
-rw------- 1 root root  213 May 25  2015 Hotspot 6
-rw------- 1 root root  350 Oct 19 23:25 Hotspot 7
-rw------- 1 root root  219 Jan 19  2015 Hotspot 8
-rw------- 1 root root  219 Oct  1  2015 XXXXXXXXXXXXXX
-rw------- 1 root root  423 Jun 30 08:09 HUAWEI-E934
-rw------- 1 root root  353 Jun 23 14:15 HUAWEI-EDF0
-rw------- 1 root root  369 Jun 17 09:46 XXXXXXXXXXXXX
-rw------- 1 root root  412 Oct 25 09:50 XXX
-rw------- 1 root root  358 Jun  2 10:56 xxxxxxx
-rw------- 1 root root  322 Sep  3  2015 XXXXX_XXXX-XXXXX
-rw------- 1 root root  426 Aug 20 08:50 XXXXXXXXXXXX
-rw------- 1 root root  231 May 10  2015 [email protected]
-rw------- 1 root root  339 Dec  6  2014 xxxxxxxxxxxx
-rw------- 1 root root  217 Oct  1  2015 XXXXXXXXXXXXXXX
-rw------- 1 root root  368 Jan 28  2016 Lenovo A6000
-rw------- 1 root root  317 Oct 12  2015 LenovoX
-rw------- 1 root root  233 Jan 26  2015 linksys
-rw------- 1 root root  283 May 23 21:32 Linksys00708
-rw------- 1 root root  283 May 10  2016 Linksys00952
-rw------- 1 root root  373 May 10  2016 Linksys00952 1
-rw------- 1 root root  235 Sep  3  2015 linksys 1
-rw------- 1 root root  235 Sep 17  2015 linksys 2
-rw------- 1 root root  320 May 26  2015 XXXXXXXXXXXXXXXXXX
-rw------- 1 root root  434 Oct  5 10:34 Lumire Ballroom
-rw------- 1 root root  428 Oct 26 18:04 Lumire Hotel
-rw------- 1 root root  328 Sep  7 14:24 LUMIRE
-rw------- 1 root root  340 Sep  7 14:24 lumire_XXXXX
-rw------- 1 root root  211 May  8  2015 XXXXXXXXXXXX
-rw------- 1 root root  285 Mar 22  2016 Mercure Wifi
-rw------- 1 root root  312 Sep 16  2015 Mercure Free
-rw------- 1 root root  225 Sep 16  2015 Mercure-HotSpoT
-rw------- 1 root root  377 Jan 18  2016 XXXXXXXXXXXXXXXXXXXXXXX
-rw------- 1 root root  211 Nov 24  2014 Mi Phone Network
-rw------- 1 root root  330 Aug  3 10:22 XXXXXXXX
-rw------- 1 root root  219 Nov  3  2015 M_Regency_4C
-rw------- 1 root root  219 Nov  2  2015 M_Regency_4D
-rw------- 1 root root  331 Nov  2  2015 M_regency_Hotel
-rw------- 1 root root  329 Nov  3  2015 XXXXXXXXX@AE70
-rw------- 1 root root  361 May 27 22:49 netzone
-rw------- 1 root root  275 Jun 20 21:22 net-zone
-rw------- 1 root root  365 Jun 24 22:18 net-zone 1
-rw------- 1 root root  275 May 23 21:44 netzone 1
-rw------- 1 root root  412 Aug 24 09:18 XXXXXXXXXXXX
-rw------- 1 root root  298 Oct  1  2015 PBN01
-rw------- 1 root root  235 Nov 16  2015 Public Wifi XXXXXXXX
-rw------- 1 root root  293 Mar 22  2016 XXXXXXXXXXXXXX @MCC
-rw------- 1 root root  322 Feb 14  2015 xxxxxxxk-3 24GHz
-rw------- 1 root root  362 Feb  3  2016 XXXXX 503
-rw------- 1 root root  323 Nov  3  2015 XXXXXXXXXXX
-rw------- 1 root root  231 Mar 31  2015 Sheraton-GuestRoom
-rw------- 1 root root  309 Nov  2  2015 xxxx
-rw------- 1 root root  228 Nov 25  2014 XXXX
-rw------- 1 root root  402 Oct 27 09:03 XXXX007
-rw------- 1 root root  415 Sep  7 09:44 XXXX008
-rw------- 1 root root  313 Oct  8  2015 XXXX01
-rw------- 1 root root  343 Feb 15  2016 XXXX02
-rw------- 1 root root  402 Sep 20 08:10 XXXX02 1
-rw------- 1 root root  417 Oct 27 09:06 XXXX_XXX
-rw------- 1 root root  348 Feb  3  2016 XXXXXXXX
-rw------- 1 root root  215 Mar 31  2015 XXXX-Temp
-rw------- 1 root root  373 May 10  2016 small-network
-rw------- 1 root root  267 Jun  7 09:54 XXXXX
-rw------- 1 root root  312 Apr  1  2015 XXXXX_21A4F8
-rw------- 1 root root  239 Dec  3  2015 THE RESIDENCE
-rw------- 1 root root  325 Nov  2  2015 TP-LINK_8488
-rw------- 1 root root  229 Nov  2  2015 TP-LINK_AP_473EBF
-rw------- 1 root root  329 Nov  1  2015 TP-LINK_F08488
-rw------- 1 root root  203 Sep 16  2015 xxxxx
-rw------- 1 root root  343 Jan 25  2016 xxxxxx
-rw------- 1 root root  211 Oct  8  2015 @wifi.xx
-rw------- 1 root root  297 Nov 16  2015 WIFI-PUSINTEK
-rw------- 1 root root  267 Jun 24 22:22 Wired connection 1
-rw------- 1 root root  246 Jan 27  2016 Wired connection 2
-rw------- 1 root root  246 Mar 23  2016 Wired connection 3
-rw------- 1 root root  246 Jun 13 08:48 Wired connection 4
-rw------- 1 root root  246 Jun 13 08:49 Wired connection 5
-rw------- 1 root root  221 Jan 22  2015 Wireless 8th Floor
user@hostname:/etc/NetworkManager/system-connections$

2. To be able to specifically choose the file which is suitable with the access point or the wireless connection intended or to be searched, just combine it with the following command :

ls -al | grep

For an example :

user@hostname:/etc/NetworkManager/system-connections$ cat aston
cat: aston: Permission denied
user@hostname:/etc/NetworkManager/system-connections$

3. Since the file itself owned by root, normal user cannot be used to display the content of wireless connection file. As shown in the above output comand’s execution. So, switch to root user first as shown below :

user@hostname:/etc/NetworkManager/system-connections$ sudo su -
[sudo] password for user:
root@hostname:~#

4. After successfully switch to root user, the content of wireless connection property file can be shown by typing the following command :

cat file_name

Below is the sample of output command’s execution ::

root@hostname:~# cd /etc/NetworkManager/system-connections/
root@hostname:/etc/NetworkManager/system-connections# cat Guest

Below is the content of the file :

[connection] 
id=Aston 
uuid=9f63e5e2-85fe-42bb-9b9b-e5a328d4b734 
type=802-11-wireless
[802-11-wireless] 
ssid=Aston mode=infrastructure 
mac-address=5C:51:4F:70:2E:07 
security=802-11-wireless-security 
[802-11-wireless-security] 
key-mgmt=wpa-psk 
auth-alg=open 
psk=playback 
[ipv4] method=auto 
[ipv6] method=auto 
root@hostname:/etc/NetworkManager/system-connections#

5. The intended pasword is located in the ‘psk’ field variable and in the above context, the value of it is ‘playback’. So, the wireless password of SSID named ‘aston’ is ‘playback’.

Finally it can be shared among your colleagues or anyone who really need it.

Leave a Reply