Linux iwconfig - 通过终端上的 wifi 连接网络

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14119446/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 18:09:48  来源:igfitidea点击:

iwconfig - connect network via wifi on terminal

linuxterminalwifiraspberry-piraspbian

提问by irukeru

On raspberry pi

在树莓派上

irukeru@raspberrypi ~ $ sudo iwconfig wlan0 mode managed
irukeru@raspberrypi ~ $ sudo iwconfig wlan0 channel 11
irukeru@raspberrypi ~ $ sudo iwconfig wlan0 essid linksys
irukeru@raspberrypi ~ $ sudo iwconfig wlan0 key xxxxxxx
Error for wireless request "Set Encode" (8B2A) :
    invalid argument "xxxxxxx".

I also tried

我也试过

irukeru@raspberrypi ~ $ sudo iwconfig wlan0 key s:xxxxxxx
Error for wireless request "Set Encode" (8B2A) :
    SET failed on device wlan0 ; Invalid argument.

Should I need to write bash code of my key ?

我是否需要编写密钥的 bash 代码?

采纳答案by Olaf Dietsche

From man iwconfig

来自man iwconfig

key/enc[ryption]
Used to manipulate encryption or scrambling keys and security mode. To set the current encryption key, just enter the key in hex digits as XXXX-XXXX-XXXX-XXXX or XXXXXXXX. To set a key other than the current key, prepend or append [index] to the key itself (this won't change which is the active key). You can also enter the key as an ASCII string by using the s: prefix. Passphrase is currently not supported.

key/enc[ryption]
用于操作加密或加扰密钥和安全模式。要设置当前加密密钥,只需以十六进制数字形式输入密钥,如 XXXX-XXXX-XXXX-XXXX 或 XXXXXXXX。要设置当前键以外的键,请将 [index] 前置或附加到键本身(这不会更改哪个是活动键)。您还可以使用 s: 前缀将密钥作为 ASCII 字符串输入。目前不支持密码短语。

HBAQXK7W6Yis not a hex key. If this is the ascii key, I think you should enter it as

HBAQXK7W6Y不是十六进制键。如果这是 ascii 键,我认为您应该将其输入为

sudo iwconfig wlan0 key s:HBAQXK7W6Y

But: if this is reallythe key for your for your WLAN, you should change it ASAP. Neverpost a password on a public website.

但是:如果这真的是您的 WLAN 的关键,您应该尽快更改它。切勿在公共网站上发布密码。

Update:

更新

There's a similar question at https://superuser.com/q/42460/164903. I think, especially this answer https://superuser.com/a/353818/164903is important. It seems, iwconfigdoesn't support WPA/WPA2, only unencrypted networks or WEP, which is essentially the same nowadays. So you need to use some other approach, like wpa_supplicant.

https://superuser.com/q/42460/164903 上有一个类似的问题。我认为,尤其是这个答案https://superuser.com/a/353818/164903很重要。看来,iwconfig不支持 WPA/WPA2,只支持未加密的网络或 WEP,现在基本上是一样的。所以你需要使用其他一些方法,比如wpa_supplicant.