-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·26 lines (16 loc) · 761 Bytes
/
setup.sh
File metadata and controls
executable file
·26 lines (16 loc) · 761 Bytes
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
#!/bin/bash
read -p 'access point IP/hostname: ' host
read -p 'wifi SSID: ' ssid
read -p 'wifi PSK: ' psk
read -p 'ssh username: ' user
echo "setup SSH password"
# although defaulting to method 1 (md5) the aps do (appear) to support SHA256/512
passhash=$(openssl passwd -6)
sed -e "s;<<SSID>>;$ssid;g" -e "s;<<PSK>>;$psk;g" -e "s;<<USER>>;$user;g" -e "s;<<PASSHASH>>;$passhash;g" template.cfg > new.cfg
# don't know what this is for but probably should be randomised
authkey=$(LC_ALL=C tr -dc 'A-Z' </dev/urandom | head -c32)
sed -e "s;<<AUTHKEY>>;$authkey;g" mgmt-template > mgmt
echo "default password is ubnt"
scp -O mgmt ubnt@$host:/etc/persistent/cfg/
scp -O new.cfg ubnt@$host:/tmp/
ssh ubnt@$host "cfgmtd -w -p /etc/ -f /tmp/new.cfg && reboot"