linux wifi连接 wpa2,linux连接wpa2,安装使用wpa_supplicant(ubuntu测试)

敖永丰
2023-12-01

百度了以下相关资料,很是让人心寒,中国人都干嘛去了?都是解决wifi密码的文章,所以自行google了一下英文资料,整理下放到这里

安装openssl 必需

# sudo apt-get install openssl

# sudo apt-get install libssl-dev build-essential zlibc zlib-bin libidn11-dev libidn11

下载wpa_supplicant

自行新建并cd目录(以下是目前的最新版,随着时间的推移就不一定了)

# wget http://hostap.epitest.fi/releases/wpa_supplicant-2.0.tar.gz

# tar -xzvf  wpa_supplicant-2.0.tar.gz

# cd wpa_supplicant-2.0

# cd wpa_supplicant

# vi .config

把以下内容粘贴保存

#

#.config

#

# Uncomment following two lines and fix the paths if you have installed openssl

# in non-default location

#CFLAGS += -I/usr/local/openssl/include

#LIBS += -L/usr/local/openssl/lib

# Driver interface for Host AP driver

#CONFIG_DRIVER_HOSTAP=y

# Driver interface for Agere driver

#CONFIG_DRIVER_HERMES=y

# Change include directories to match with the local setup

#CFLAGS += -I../../hcf -I../../include -I../../include/hcf

#CFLAGS += -I../../include/wireless

# Driver interface for Prism54 driver

# (Note: Prism54 is not yet supported, i.e., this will not work as-is and is

# for developers only)

#CONFIG_DRIVER_PRISM54=y

# Driver interface for ndiswrapper

#CONFIG_DRIVER_NDISWRAPPER=y

# Driver interface for Atmel driver

#CONFIG_DRIVER_ATMEL=y

# Driver interface for Broadcom driver

#CONFIG_DRIVER_BROADCOM=y

# Example path for wlioctl.h; change to match your configuration

#CFLAGS += -I/opt/WRT54GS/release/src/include

# Driver interface for Intel ipw2100/2200 driver

#CONFIG_DRIVER_IPW=y

CONFIG_DRIVER_MADWIFI=y

# Change include directories to match with the local setup

CFLAGS += -I../madwif

CONFIG_DRIVER_WEXT=y

# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)

#CONFIG_DRIVER_BSD=y

#CFLAGS += -I/usr/local/include

#LIBS += -L/usr/local/lib

# Driver interface for Windows NDIS

#CONFIG_DRIVER_NDIS=y

#CFLAGS += -I/usr/include/w32api/ddk

#LIBS += -L/usr/local/lib

# For native build using mingw

#CONFIG_NATIVE_WINDOWS=y

# Additional directories for cross-compilation on Linux host for mingw target

#CFLAGS += -I/opt/mingw/mingw32/include/ddk

#LIBS += -L/opt/mingw/mingw32/lib

#CC=mingw32-gcc

# Driver interface for development testing

#CONFIG_DRIVER_TEST=y

# Driver interface for wired Ethernet drivers

#CONFIG_DRIVER_WIRED=y

CONFIG_IEEE8021X_EAPOL=y

# EAP-MD5 (automatically included if EAP-TTLS is enabled)

CONFIG_EAP_MD5=y

# EAP-MSCHAPv2 (automatically included if EAP-PEAP is enabled)

CONFIG_EAP_MSCHAPV2=y

# EAP-TLS

CONFIG_EAP_TLS=y

# EAL-PEAP

CONFIG_EAP_PEAP=y

# EAP-TTLS

CONFIG_EAP_TTLS=y

# EAP-GTC

CONFIG_EAP_GTC=y

# EAP-OTP

CONFIG_EAP_OTP=y

# LEAP

CONFIG_EAP_LEAP=y

# PKCS#12 (PFX) support (used to read private key and certificate file from

# a file that usually has extension .p12 or .pfx)

CONFIG_PKCS12=y

# Include control interface for external programs, e.g, wpa_cli

CONFIG_CTRL_IFACE=y

粘贴到此结束

安装

# make && make install

通过以下命令连接

# wpa_passphrase

conf文件:

For WPA-PSK

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

eapol_version=1

# ap_scan=2 was the one for me you may try 0 or 1 indstead of 2

ap_scan=2

fast_reauth=1

network={

ssid="my_network"

proto=WPA

key_mgmt=WPA-PSK

pairwise=TKIP

group=TKIP

psk="secret_password"

}

For WPA2-Personal

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

ap_scan=1

network={

ssid="my_network"

proto=RSN

key_mgmt=WPA-PSK

pairwise=CCMP TKIP

group=CCMP TKIP

psk="secret_password"

}

Starting wpa_supplicant

 类似资料: