Skip to content

Instantly share code, notes, and snippets.

@qguv
Last active March 4, 2024 17:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qguv/d2c7f948fab00903cb67 to your computer and use it in GitHub Desktop.
Save qguv/d2c7f948fab00903cb67 to your computer and use it in GitHub Desktop.
Automatic WPA Supplicant Configuration for GNU/Linux

Get a hard-wired ethernet connection

Disable all other network daemons

This is just an example; disable and stop all active daemons.

sudo systemctl stop dhcpcd
sudo systemctl disable dhcpcd

Set up wpa_supplicant

sudo -i
curl https://gist.githubusercontent.com/qguv/d2c7f948fab00903cb67/raw/8c99ba2f033bf8dde571733c3a41484c0611ef03/wpa_supplicant.conf > /etc/wpa_supplicant/wpa_supplicant.conf
curl https://gist.githubusercontent.com/qguv/d2c7f948fab00903cb67/raw/64b281e6d787709e0a22a231317f50a1f0a25fe3/network-wireless@.service > /etc/systemd/system/network-wireless@.service
exit

Test your configuration

# find your wireless interface
iw dev

# replace wlp1s0 with your interface name
sudo systemctl start network-wireless@wlp1s0

# make sure it works
ping -c 3 google.com

Run automatically

# replace wlp1s0 with your interface name
sudo systemctl enable network-wireless@wlp1s0
# Automatically load global WPA Supplicant configuration.
# this goes in /etc/systemd/system/network-wireless@.service on Arch Linux
# Rehosted from:
# https://wiki.archlinux.org/index.php/Wireless_network_configuration#Manual_wireless_connection_at_boot_using_systemd_and_dhcpcd
[Unit]
Description=Wireless network connectivity (%i)
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/ip link set dev %i up
ExecStart=/usr/bin/wpa_supplicant -B -i %i -c /etc/wpa_supplicant/wpa_supplicant.conf
ExecStart=/usr/bin/dhcpcd %i
ExecStop=/usr/bin/ip link set dev %i down
[Install]
WantedBy=multi-user.target
# WPA Supplicant Configuration
# this goes in /etc/wpa_supplicant/wpa_supplicant.conf on Arch Linux
# chown root, chmod 600
# This configuration is designed for folks living, working, or studying on the
# UCCS campus. It will connect you to the secure WPA2-Enterprise wireless
# networks scattered around campus. Change myusername and mypassword to your
# credentials.
# Be sure to use the systemd unit provided at:
# https://wiki.archlinux.org/index.php/Wireless_network_configuration#Manual_wireless_connection_at_boot_using_systemd_and_dhcpcd
# or the copy (as of 2014-06-03) reproduced here for convenience.
network={
ssid="UCCS-Wireless"
scan_ssid=1
key_mgmt=WPA-EAP
pairwise=CCMP TKIP
group=CCMP TKIP
eap=PEAP
identity="myusername@uccs.edu"
password="mypassword"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment