Low Orbit Flux Logo 2 F

WPA Supplicant

sillyfrog Example SSID for this document
mypassword123 Example passphrase for this document
wlan0 Example interface for this document

NOTE - You can use nano/vi/vim or whatever you like to edit these files.

You can generate a config file like this:


wpa_passphrase sillyfrog mypassword123 > /etc/wpa_supplicant/example.conf

You can setup a config file by hand like this:

/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/run/wpa_supplicant ctrl_interface_group=wheel update_config=1 ap_scan=1 country=US network={ ssid="sillyfrog" psk=59e0d07fa4c7741797a4e394f38a5c321e3bed51d54ad5fcbd3f84bc7415d73d }

You can use a clear text password instead of a key like this:


psk="mypassword123"

No password

If you prefer not to use a password you can do so like this:


network={
   ssid="MYSSID"
   key_mgmt=NONE
}

Connect to AP

Start up wpa_supplicant and associate to the AP:


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

Use this command to get an IP ( temporary, won’t survive reboot, need to already have dhcpcd package installed previously for this command to work ):



dhcpcd

Persistent Wifi

If you want your wifi connection to survive reboot you can configure systemd-networkd to connect to the AP and request IP info with DHCP.

You need to have a wpa_suplicant config file that includes the wifi NIC name and follows this naming convention. I prefer to just create a link.



cd /etc/wpa_supplicant/
ln -s wpa_supplicant.conf wpa_supplicant-wlan0.conf

Create a systemd network interface file for the interface.

vi /etc/systemd/network/30-wifi.network
[Match] Name=wlan0 [Network] DHCP=ipv4 [DHCPv6] UseDomains=true

Enable this service ( use the correct NIC name ):



systemctl enable wpa_supplicant@wlan0.conf

Reboot just to be sure everything is working:



reboot

Verify that you have an IP with either of these commands:



ip a
ifconfig -a

References