wpa_supplicant 1: Basic Wireless Connections
It is possible, and fairly easy, to manage wireless connections on a daily basis using only
Besides, it is worthwhile to know how to use
wpa_supplicant, as it is part of the base system on all Linux distributions, as well as on NetBSD and on FreeBSD, and it is usually the most reliable way of managing wireless connections on devices like the Raspberry Pi, or on certain installation media.
Usually, the network SSID and the WPA password are required to connect to a password-protected Wi-Fi network.
We can either edit the
/etc/wpa_supplicant/wpa_supplicant.conf file manually to provide the required information, or we can use
wpa_passphrase to generate a WPA PSK from the password, and append it to the configuration file.
Let's try connecting to a network called "Network" with the password "password".
First, we need to make the
/etc/wpa_supplicant directory, if it doesn't exist.
The commands are executed as root, but
sudo can be used instead.
Then, we need to save our network information to the configuration file.
wpa_passphrase program requires the SSID and the WPA password.
wpa_passphrase program writes to standard output.
We can take this output, remove the line containing the actual password with
sed, and write (or, in most cases, append in order to avoid overwriting the existing configuration) it to the configuration file by piping it into
Below is the command to do it.
This is actually all the configuration needed to connect to a wireless network.
This process can be repeated when it is needed to connect to another network.
The configuration file looks like this right now:
wpa_cli is a text-based frontend for interacting with
wpa_supplicant, which I typically do not use.
In order to be able to use it when needed (presumably as a user in the wheel group), the following lines should be added to the beginning of the configuration file:
We can now start
wpa_supplicant using the command below.
-i option specifies the wireless interface.
The interface name can be obtained using the
Wireless interface names on Linux generally start with "w".
Then, we run a DHCP client to obtain an IP address. In this guide,
dhcpcd is used.
We can use
ping to make sure that the connection is established.
We can also enable the
wpa_supplicant service (and the DHCP client, if it has not been already enabled) to start wireless networking on boot.
This process is depends the distribution or the OS.
Here is how to do it on Void Linux: