Tuesday, July 18, 2017

Tiny script for connecting to wireless AP

# Connect to a Wireless Router
# $1 = interface (use ip link)

#!/bin/bash

# Enable the interface
ip link set $1 up
# Find access point names
iw dev $1 scan | grep SSID

# Select SSID and enter password
printf "SSID: "
read SSID
printf "pass: "
read -s PASS

# Connect
TEMPFILE=`mktemp`
wpa_passphrase $SSID $PASS > $TEMPFILE
wpa_supplicant -i $1 -c $TEMPFILE -B
rm $TEMPFILE
dhcpcd $1