Wifi

網路管理器連接到隱藏網路 - 指定密碼 - 不是身份驗證類型

  • March 3, 2021

我已經看到如何使用以下方法連接到隱藏的 wifi 網路:

nmcli c add type wifi con-name $ssid ifname $adapter ssid $ssid
nmcli con modify $ssid wifi-sec.key-mgmt wpa-psk
nmcli con modify $ssid wifi-sec.psk $password
nmcli con up $ssid

為了清楚起見,在上面的程式碼中,連接名稱被設置為與 SSID 相同的名稱。

但是,這需要我知道 wifi 身份驗證的類型。

當連接到廣播它的 SSID 的 AP 時,網路管理器似乎可以確定正在使用哪種類型的身份驗證,因此我只需要使用以下內容提供密碼:

nmcli -w 30 device wifi connect $ssid password $password ifname $adapter

有沒有一種方法可以連接到隱藏的 wifi AP,nmcl這樣我只需要提供密碼、SSID 和設備,而不是使用的身份驗證類型,類似於連接到非隱藏 AP 不需要我指定身份驗證類型?

使用nmcliwith 時device wifi connect,嘗試將hidden選項設置為yes

手冊摘錄

$$ 1 $$:

wifi connect (B)SSID [password password] [wep-key-type {key | phrase}] [ifname ifname] [bssid BSSID] [name name] [private {yes | no}] [hidden {yes | no}]
 Connect to a Wi-Fi network specified by SSID or BSSID. The command finds a matching connection or creates one and then activates it on a device. This is a
 command-line counterpart of clicking an SSID in a GUI client. If a connection for the network already exists, it is possible to bring up (activate) the existing
 profile as follows: nmcli con up id name. Note that only open, WEP and WPA-PSK networks are supported if no previous connection exists. It is also assumed that
 IP configuration is obtained via DHCP.

 If --wait option is not specified, the default timeout will be 90 seconds.

 Available options are:

 [...]

 hidden
   set to yes when connecting for the first time to an AP not broadcasting its SSID. Otherwise, the SSID would not be found and the connection attempt would
   fail.


 [1]: https://developer.gnome.org/NetworkManager/stable/nmcli.html

引用自:https://unix.stackexchange.com/questions/635909