Skip to content

Instantly share code, notes, and snippets.

@hsur
Created October 22, 2021 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsur/aeb97d134b218019f9f7f3b538348f50 to your computer and use it in GitHub Desktop.
Save hsur/aeb97d134b218019f9f7f3b538348f50 to your computer and use it in GitHub Desktop.
Wifi setup script for WPA Enterprise on Raspberry Pi OS
read -p "SSID: " ssid < /dev/tty
read -p "Username: " uname < /dev/tty
read -sp "Password: " passwd < /dev/tty
passwd=`echo -n "$passwd" | iconv -t utf16le | openssl md4 | awk '{print $2}'`
sudo tee /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null <<EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=JP
network={
ssid="$ssid"
priority=1
proto=RSN
key_mgmt=WPA-EAP
pairwise=CCMP
auth_alg=OPEN
eap=PEAP
identity="$uname"
password=hash:$passwd
phase1="tls_disable_tlsv1_0=0 tls_disable_tlsv1_1=0 peaplabel=0"
phase2="auth=MSCHAPV2"
openssl_ciphers="DEFAULT@SECLEVEL=2"
}
EOF
sudo chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf
sudo chown root:root /etc/wpa_supplicant/wpa_supplicant.conf
sudo systemctl restart dhcpcd
cd /tmp
sudo apt install -y libnl-3-dev libdbus-1-dev libnl-genl-3-dev libssl-dev
wget https://w1.fi/releases/wpa_supplicant-2.9.tar.gz
tar -xvf wpa_supplicant-2.9.tar.gz
cd wpa_supplicant-2.9/wpa_supplicant/
cp -p defconfig .config
make && sudo make install
sudo cp -a {/lib/,/etc}/systemd/system/wpa_supplicant.service
sudo systemctl stop wpa_supplicant
sudo systemctl disable wpa_supplicant
sudo sed -i -e 's#/sbin/wpa_supplicant#/usr/local/sbin/wpa_supplicant#' /etc/systemd/system/wpa_supplicant.service
sudo systemctl daemon-reload
sudo systemctl start wpa_supplicant
sudo systemctl enable wpa_supplicant
sudo systemctl restart dhcpcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment