0

I just want to get wireless access points name or ssid list which do not prompt to enter password using shell script in ubuntu.

Or I can say that I want to get ssid or wireless access point name list whose password are saved or remembered by machine. So when user try to connect with them then it will connect automatically ( which do not prompt to enter password manually in popup).

I am using below commands to get ssid's.

  1. nmcli -t -f ssid dev wifi| cut -d\' -f2
  2. iwlist wlan0 scan

These commands showing all ssid's but I need only ssid whose password are saved or remembered by machine.

If anybody has any idea regarding my issue then please let me know.

Here is the output of command "sudo iwlist wlan0 scan" as per below.

wlan0     Scan completed :
          Cell 01 - Address: xxxxxxx
                    Channel:6
                    Frequency:2.437 GHz (Channel 6)
                    Quality=46/70  Signal level=-64 dBm  
                    Encryption key:on
                    ESSID:"Mars"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000012d307fe635
                    Extra: Last beacon: 148ms ago
                    IE: Unknown: 00044D617273
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030106
                    IE: Unknown: 2A0102
                    IE: Unknown: 32043048606C
                    IE: Unknown: 2D1A2C181EFF00000000000000000000000000000000000000000000
                    IE: Unknown: 3D1606000000000000000000000000000000000000000000
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : TKIP CCMP
                        Authentication Suites (1) : PSK
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : TKIP CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
                    IE: Unknown: DD1E00904C332C181EFF00000000000000000000000000000000000000000000
                    IE: Unknown: DD1A00904C3406000000000000000000000000000000000000000000
                    IE: Unknown: DD0600E04C020160
                    IE: Unknown: DD930050F204104A0001101044000102103B00010310470010630412531019200612289CD643CC009810210012442D4C696E6B20436F72706F726174696F6E1023000D442D4C696E6B20526F75746572102400084449522D3630304C1042000D32303037303431332D303030311054000800060050F2040001101100084449522D3630304C1008000226881049000600372A000120

 Cell 02 - Address: xxxxxxx
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=48/70  Signal level=-62 dBm  
                    Encryption key:on
                    ESSID:"qw4hd"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000002810a6e9d4
                    Extra: Last beacon: 1352ms ago
                    IE: Unknown: 00057177346864
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030101
                    IE: Unknown: 2A0100
                    IE: Unknown: 32043048606C
                    IE: Unknown: 2D1A2C181EFF00000000000000000000000000000000000000000000
                    IE: Unknown: 3D1601001100000000000000000000000000000000000000
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : TKIP CCMP
                        Authentication Suites (1) : PSK
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : TKIP CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
                    IE: Unknown: DD1E00904C332C181EFF00000000000000000000000000000000000000000000
                    IE: Unknown: DD1A00904C3401001100000000000000000000000000000000000000
                    IE: Unknown: DD0600E04C020160

 Cell 03 - Address: xxxxxx
                    Channel:8
                    Frequency:2.447 GHz (Channel 8)
                    Quality=46/70  Signal level=-64 dBm  
                    Encryption key:on
                    ESSID:"willdo"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000003ab3a54a73
                    Extra: Last beacon: 176ms ago
                    IE: Unknown: 000677696C6C646F
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030108
                    IE: Unknown: 2A0100
                    IE: Unknown: 32043048606C
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (1) : TKIP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
                    IE: Unknown: DD0600E04C020160

Thanks.

2

I would say that you need three things

  1. inspect the result of sudo iwlist wlan0 scan | grep "Encryption key:off" -A 1 for any network not requiring any password that are currently available and possibly new for the system

  2. inspect the content of /etc/NetworkManager/system-connections to get a list of saved networks for the system. If a network is saved with system-wide access then you'll also find the password there (psk field), if it doesn't require any password then it won't have security fields.

  3. For networks for which the network-manager doesn't have system-wide password set, the password is saved in the gnome-keyring wallet. You can learn how to interact with it by starting from here: https://blog.schmichael.com/2008/10/30/listing-all-passwords-stored-in-gnome-keyring/

This, of course, assuming you're on a regular Ubuntu distro.

  • Thanks for your reply. iwlist wlan0 scan lists all the wireless access points. – User2546 Mar 17 '16 at 9:07
  • You just need to filter out those which have the encryption off, e.g. sudo iwlist wlan0 scan | grep "Encryption key:off" -A 1 – Patrick Trentin Mar 17 '16 at 9:25
  • I am getting all wireless access point with encryption on so command sudo iwlist wlan0 scan | grep "Encryption key:off" -A 1 not giving me any result. I need only ssid whose password are saved or remembered by machine. – User2546 Mar 17 '16 at 9:33
  • Please update your question with the output of sudo iwlist wlan0 scan, so we can determine why you don't get any public AP when running my code. Notice that this command isn't enough to do what you want to accomplish, as I mentioned in the answer you ought to complete all 3 tasks. -- ETA: then go with steps 2 and 3 – Patrick Trentin Mar 17 '16 at 9:41
  • I have updated my question as you have suggested. I am getting total 3 ssid. 2 ssid out of 3 remember/save password into my machine. ESSID:"Mars" and ESSID:"qw4hd" remember/save password and ESSID:"willdo" does not save. I also got your point1 and 2 and verified the same at my end and working as you have suggested but point 3 is not clear to me. – User2546 Mar 17 '16 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.