在 ubuntu 中使用 shell 脚本获取不提示输入密码的无线接入点名称或 ssid

在 ubuntu 中使用 shell 脚本获取不提示输入密码的无线接入点名称或 ssid

我只是想在 ubuntu 中使用 shell 脚本获取不提示输入密码的无线接入点名称或 ssid 列表。

或者我可以说我想获取机器保存或记住其密码的 ssid 或无线接入点名称列表。因此,当用户尝试连接它们时,它将自动连接(不会在弹出窗口中提示手动输入密码)。

我正在使用以下命令来获取 ssid。

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

这些命令显示所有 ssid,但我只需要机器保存或记住的密码的 ssid。

如果有人对我的问题有任何想法,请告诉我。

以下是命令“sudo iwlist wlan0 scan”的输出。

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

谢谢。

答案1

我想说你需要三样东西

  1. sudo iwlist wlan0 scan | grep "Encryption key:off" -A 1检查当前可用的任何不需要密码的网络的结果,以及可能的new系统的结果

  2. 检查内容以/etc/NetworkManager/system-connections获取系统已保存网络的列表。如果网络以系统范围访问权限保存,那么您还会在那里找到密码(psk字段),如果它不需要任何密码,则它将没有安全字段。

  3. 对于网络管理员没有设置系统密码的网络,密码将保存在gnome 钥匙圈钱包。你可以从这里开始学习如何与它交互:https://blog.schmichael.com/2008/10/30/listing-all-passwords-stored-in-gnome-keyring/

当然,这是假设您使用的是常规的 Ubuntu 发行版。

相关内容