Connect to WiFi using wpa_supplicant

2025-05-27

Replace wlan0 with your actual wireless interface name (wlp-, wlx-). Use ip link to list interfaces.

Bring the interface up and scan for networks.

# ip link set wlan0 up
# wpa_cli -i wlan0 scan

Give it a few seconds to scan and then see the results:

# wpa_cli -i wlan0 scan_results

Copy /etc/wpa_supplicant/wpa_supplicant.conf from another system with your configured networks (you can edit it manually) or:

# wpa_passphrase "your_SSID" "your_password" > /etc/wpa_supplicant/wpa_supplicant.conf
# chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf
  • ! use >> instead of > if you want to append to existing file

My configuration also includes:

ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=wheel
  • ctrl_interface: path where the UNIX domain socket will be created. Used for communication with frontend programs like wpa_cli
  • ctrl_interface_group: members of this group will be able to use the control socket

Associate with access point and use dhcpcd to request ip address.

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

For persistent setup enable wpa_supplicant and dhcpcd services.