欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

如何使用wpa_supplicant从命令行配置Linux无线

程序员文章站 2022-05-24 07:50:44
...

wpa_supplicant is used to connect wireless networks. wpa_supplicant.conf  file is used to store related configuration file about the wireless network. Also wireless security policy is configured with this file.

wpa_supplicant用于连接无线网络。 wpa_supplicant.conf文件用于存储有关无线网络的相关配置文件。 此文件还配置了无线安全策略。

安装wpa_supplicant软件包 (Install wpa_supplicant Package)

In most of cases the wpa_supplicant package is installed by default but we can use following commands in order to install this package.

在大多数情况下,默认情况下会安装wpa_supplicant软件包,但我们可以使用以下命令来安装此软件包。

Fedora,RHEL,CentOS (Fedora, RHEL, CentOS)

$ sudo yum install wpa_supplicant

Ubuntu,Debian,Mint,Kali (Ubuntu, Debian, Mint, Kali)

$ sudo apt install wpa_supplicant

帮助wpa_supplicant (Help wpa_supplicant)

More detailed help information can be show with -h option like below.

可以使用-h选项显示更详细的帮助信息,如下所示。

$ wpa_supplicant -h
如何使用wpa_supplicant从命令行配置Linux无线
Help wpa_supplicant
帮助wpa_supplicant

指定接口和配置文件 (Specify Interface and Configuration File)

The most basic and used way to run wpa_supplicant is providing the interface name and the configuration file. We can use -i to specify interface and -c for configuration file like below.

运行wpa_supplicant最基本,最常用的方法是提供接口名称和配置文件。 我们可以使用-i来指定接口,使用-c来配置文件,如下所示。

$ wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

在后台运行守护程序 (Run Daemon In Background)

The deafult behaivour of wpa_supplicant is running on foregound which will take terminal busy. This will also create the stability problems where closing terminal will kill network connection too. We can use -B  option for background connection.

wpa_supplicant的默认行为正在前途运行,这将使终端繁忙。 这还将产生稳定性问题,其中关闭的终端也将终止网络连接。 我们可以使用-B选项进行后台连接。

$ wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

无线配置样本 (Sample Wireless Configuration)

Here is a sample configuration which has SSID name poftut and key management is specified as WPA_PSK .

这是一个具有SSID名称poftut的示例配置,并且**管理指定为WPA_PSK

network={
 ssid="poftut"
 scan_ssid=1
 key_mgmt=WPA-PSK
 psk="very se+ret passphrase"
}
了解更多如何在Windows中获取Mac地址?

翻译自: https://www.poftut.com/how-to-configure-linux-wireless-from-command-line-with-wpa_supplicant/