从命令行连接到无线(WPA)

从命令行连接到无线(WPA)

我希望能够从命令行连接到我的 WIFI(WPA)网络。我从存储库安装了 wpasupplicant 并创建了两个文件。一个是脚本,另一个是配置文件。

Bash 脚本:

#!/bin/sh
iface=wlan0

#shut down interface
ifconfig $iface down

#set ad-hoc/management of wireless device
iwconfig $iface mode Managed

#enable interface
ifconfig $iface up

#stop any persistent wireless wpa2 sessions
killall wpa_supplicant

#apply WPA/WPA2 personal settings to device
wpa_supplicant -B -Dwext -i $iface -c ./wireless-wpa.conf -dd

#obtain an IP address
dhclient $iface

配置文件:

# config file using WPA/WPA2-PSK Personal key.

ctrl_interface=/var/run/wpa_supplicant

network={
ssid="ssid"
scan_ssid=1
key_mgmt=WPA-PSK
psk="pass"
}

但是我一直收到这个错误:

Initializing interface 'wlan0' conf './wireless-wpa.conf' driver 'wext' ctrl_interface 'N/A' bridge 'N/A'
Configuration file './wireless-wpa.conf' -> '/home/itsy/Desktop/./wireless-wpa.conf'
Reading configuration file '/home/itsy/Desktop/./wireless-wpa.conf'
Failed to read or parse configuration '/home/itsy/Desktop/./wireless-wpa.conf'.
Failed to add interface wlan0
Cancelling scan request
Cancelling authentication timeout

我甚至尝试用 wpa_passphrase 替换“myssid”,输入密码并将其粘贴到 conf 文件中。它仍然不起作用。有人能告诉我我做错了什么吗?

答案1

将 WPA/WPA2 个人设置应用于设备:

wpa_supplicant -B -Dwext -i $iface -c ./wireless-wpa.conf -dd

还可以尝试将 WPA/WPA2 个人设置应用于设备:

wpa_supplicant -B -Dwext -i $iface -c /etc/wireless-wpa.conf -dd

目录列表可能不完整。

相关内容