Table of Contents

Connect to a wireless network with wpa_supplicant

If your usual GUI program to connect to wifi networks, e.g. wicd or NetworkManager is not available, you can connect to a wireless network by manually scanning and editing wpa_supplicant's config files.

see also: Arch Wiki on wpa_supplicant

one-liner to connect with known SSID and passphrase

Run this on a root shell. sudo will not suffice:

wpa_supplicant -B -i INTERFACE -c <(wpa_passphrase MYSSID PASSPHRASE)

Find wireless interfaces with iw list.

systemd-networkd

/etc/systemd/network/INTERFACE.network
[Match]
Name=INTERFACE

[Network]
DHCP=yes
/etc/wpa_supplicant/wpa_supplicant-INTERFACE.conf
ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1
fast_reauth=1

network={
    ssid="MYSSID"
    psk="MYSUPERSECUREPASSWORD"
    priority=1
}

start that shit up:

systemctl enable systemd-networkd
systemctl enable wpa_supplicant@INTERFACE
systemctl start systemd-networkd
systemctl start wpa_supplicant@INTERFACE

Troubleshooting

I connected to the WLAN, but still can't access the network

Do you have an IP address? Check this with ip a. If not, you have to obtain an IP via dhcpcd INTERFACE or set it manually with ip a add ADDRESS dev INTERFACE.

Could be that your /etc/resolv.conf doesn't list any DNS servers. Either add this:

/etc/resolv.conf
nameserver 127.0.0.1

(replace 127.0.0.1 with the IP address of your router/DNS server)

or use systemd-resolved:

mv /etc/resolv.conf /etc/resolv.conf.before-the-systemd-nation-attacked
systemctl enable --now systemd-resolved

systemd-resolved populates the /etc/resolv.conf with known DNS servers automagically, but you can still add them manually:

…
DNS=1.2.3.4
FallbackDNS=5.6.7.8
…