83

I want to find the password for the wireless network that I am currently connected to (and I entered the password when connecting to the network). How can I do this in Ubuntu?

9 Answers9

83

Left click the connections icon at the top right.

Choose edit connections and then choose edit on the connection you need and click the wireless security.

1

And click the 'show password'checkbox

2

anand mbs
  • 431
Rinzwind
  • 299,756
46

If you want to do this with the command line, the wireless network configuration files are saved in the /etc/NetworkManager/system-connections/ directory. You can get them all at once like this:

sudo grep -r '^psk=' /etc/NetworkManager/system-connections/

This will give you output like this:

/etc/NetworkManager/system-connections/MyExampleSSID:psk=12345
/etc/NetworkManager/system-connections/AnotherSSID:psk=password

You can suppress the filename with the -h flag:

sudo grep -hr '^psk=' /etc/NetworkManager/system-connections/

The output is easier to read at a glance:

psk=12345
psk=password
MRTgang
  • 661
21

In the command line:

nmcli dev wifi show-password
  • First one down the line that worked perfectly. – Matt Alexander Oct 01 '21 at 11:33
  • This one is not only the only working solution for me, but it even displays a nice Qr code (yes in command line!) that you can scan on your mobile to quickly add the wifi! Thanks a lot! – tobiasBora Jan 03 '22 at 08:17
17

Open a terminal (press Ctrl+Alt+T), then type:

sudo cat /etc/NetworkManager/system-connections/<your-SSID>

(Of course, substitute <your-SSID> with your network's name.)

Look for the line named psk. This should contain your password, after the = sign.

psk=notreallymypassword
Eliah Kagan
  • 117,780
roadmr
  • 34,222
  • 9
  • 81
  • 93
4

This will give you the password for your current connection.

sudo grep psk= /etc/NetworkManager/system-connections/*

Or

sudo grep psk= /etc/NetworkManager/system-connections/(YOUR-SSID)
user.dz
  • 48,105
Stryc9
  • 41
2

here is a one liner to make @David Foerster answer more useful

MYCWD=`pwd`; cd /etc/NetworkManager/system-connections/ ; sudo grep -e '^psk=' * | less ; cd $MYCWD
1

Using nmcli on Ubuntu 18.04, replace WIFINAME with the wireless network name (ssid):

nmcli --show-secrets connection show WIFINAME | grep 802-11-wireless-security.psk:

show-password does not work for me

1

you can just type ls /etc/NetworkManager/system-connections/ and it will show the name of your network, so just press the up arrow on keyboard and type the name of your connections and change ls to sudo cat

the password will be psk

0

Going further with MRTgang second command to remove "psk=" leaving only the password

sudo grep -hr '^psk=' /etc/NetworkManager/system-connections/ | sed 's|psk=||g'
bonelifer
  • 31
  • 5