无法通过命令行连接 wifi

无法通过命令行连接 wifi

我只是尝试使用命令行连接到我的 WPA2 网络。过去几个小时我尝试了各种方法,但都没有成功。

尝试 #1

因此我尝试使用/etc/network/interfaces以下信息编辑该文件:

auto wlan0
iface wlan0 inet dhcp
       wpa-ssid "my ssid with spaces"
       wpa-psk "my cleartext password"

ifconfig down尝试使用和关闭接口ifup -v wlan0,结果出现以下错误:

ifup: configuring interface wlan0=wlan0 (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/ethtool
run-parts: executing /etc/network/if-pre-up.d/ifenslave
+ [ inet = meta ]
+ IF_BOND_SLAVES=
+ [  ]
+ [  ]
+ [ -z  ]
+ exit
run-parts: executing /etc/network/if-pre-up.d/macchanger
run-parts: executing /etc/network/if-pre-up.d/vlan
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
wpa_supplicant: wpa-driver nl80211,wext (default)
wpa_supplicant: /sbin/wpa_supplicant -s -B -P /run/wpa_supplicant.wlan0.pid -i wlan0 -D nl80211,wext -C /run/wpa_supplicant
Starting /sbin/wpa_supplicant...
wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
ifup: failed to bring up wlan0

尝试#2

接下来,我尝试使用 wpa_supplicant。

# wpa_passphrase "my ssid with spaces" >> /etc/wpa_supplicant.conf
<my cleartext password followed by Enter>

我尝试使用以下命令启动 wpa_supplicant:wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -Dnl80211仅显示以下输出:

Successfully initialized wpa_supplicant
wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlan0: No network configuration found for the current AP
wlan0: CTRL-EVENT-DISCONNECTED bssid=e8:fc:af:fa:e1:69 reason=3 locally_generated=1
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
wlan0: CTRL-EVENT-REGDOM-CHANGE init=COUNTRY_IE type=COUNTRY alpha2=US
wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
^Cnl80211: deinit ifname=wlan0 disabled_11b_rates=0
wlan0: CTRL-EVENT-TERMINATING

尝试#3

我也尝试过仅从命令行使用iwconfig,但这也不起作用:

# iwconfig wlan0 essid "my ssid with spaces" key "cleartext password"
Error for wireless request "Set Encode" (8B2A) :
    invalid argument "cleartext password".

尝试#4

不确定我做了什么不同的事情,但现在wpa_supplicant似乎与我的 AP 关联,然后又断开了关联。我已经验证了密码是否正确。以下是在命令行参数中未指定驱动程序的情况下运行它的输出:

Successfully initialized wpa_supplicant
wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlan0: SME: Trying to authenticate with e8:fc:af:fa:e1:69 (SSID='my ssid with spaces' freq=5240 MHz)
wlan0: Trying to associate with e8:fc:af:fa:e1:69 (SSID='ssid with spaces' freq=5240 MHz)
wlan0: SME: Trying to authenticate with e8:fc:af:fa:e1:69 (SSID='ssid with spaces' freq=5240 MHz)
wlan0: Trying to associate with e8:fc:af:fa:e1:69 (SSID='ssid with spaces' freq=5240 MHz)
wlan0: Associated with e8:fc:af:fa:e1:69
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: CTRL-EVENT-DISCONNECTED bssid=e8:fc:af:fa:e1:69 reason=3 locally_generated=1
wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
wlan0: CTRL-EVENT-REGDOM-CHANGE init=COUNTRY_IE type=COUNTRY alpha2=US
wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
^Cnl80211: deinit ifname=wlan0 disabled_11b_rates=0
wlan0: CTRL-EVENT-TERMINATING

尝试#5

现在我尝试使用wpa_cli,它似乎正在关联,但又断开了关联。我看到 auth_failure = 1,但这不可能正确,因为我只是将密码粘贴到笔记本电脑上并连接正常,将其粘贴到 CLI 中却失败了。

<3>Trying to associate with e8:fc:af:fa:e1:69 (SSID='my ssid with spaces' freq=5240 MHz)
<3>Associated with e8:fc:af:fa:e1:69
<3>CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
<3>CTRL-EVENT-DISCONNECTED bssid=e8:fc:af:fa:e1:69 reason=3 locally_generated=1
<3>CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="my ssid with spaces" auth_failures=1 duration=10 reason=CONN_FAILED
<3>CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
<3>CTRL-EVENT-REGDOM-CHANGE init=COUNTRY_IE type=COUNTRY alpha2=US
<3>CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-RESULTS

我做错了什么?似乎仅仅通过命令行连接到 Wi-Fi 就非常困难。我正在使用技嘉迷你电脑。

任何帮助将不胜感激。

相关内容