-
Notifications
You must be signed in to change notification settings - Fork 0
/
peap-wifi
executable file
·57 lines (48 loc) · 1.11 KB
/
peap-wifi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
essid="$1"
if [ "x$essid" = "x" ] ; then
echo "Usage: $0 <essid> [<identity (i.e. username)>]"
echo "e.g. $0 BK-WIFI"
echo "e.g. $0 BK-WIFI johnny"
exit 1
fi
identity="$2"
if [ -z "$identity" ] ; then
default_user="${2:-$USER}"
echo -n "Identity for $essid [$default_user]: "
read identity
identity=${identity:-$default_user}
fi
if [ -n "$pass_command" ] ; then
echo "pass_command=$pass_command"
got_password=$( $pass_command )
if [ $? -eq 0 ] ; then
password="$got_password"
else
echo "pass_command failed!"
fi
fi
if [ -z "$password" ] ; then
echo -n "Password (will not be echoed): "
read -s password
echo
fi
# wpa_supplicant isn't as clever as I thought
# password="${password//\"/\\\"}"
tmpfile=$(mktemp)
cat >$tmpfile <<EOF
ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=wheel
network={
ssid="$essid"
key_mgmt=WPA-EAP
eap=PEAP
identity="$identity"
password="$password"
priority=1
phase2="peaplabel=0"
}
EOF
wpa_supplicant -B -P /run/wpa_supplicant.wlan0.pid -i wlan0 -D nl80211,wext -c$tmpfile -W -C /run/wpa_supplicant
dhclient -v wlan0
rm -f $tmpfile