-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathethz-vpn
35 lines (30 loc) · 1.32 KB
/
ethz-vpn
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
#!/bin/bash
connect () {
TOKEN=$(sudo cat /secrets/ethzvpntoken.secret)
#place your OTP password seccret here, or choose another location. Make sure sour permissions are "chmod og-rwx ./*.secret", and user:group is root:root
sudo cat /secrets/ethzvpnpass.secret | sudo openconnect -b -u [email protected] -g student-net --useragent=AnyConnect --passwd-on-stdin --token-mode=totp --token-secret=sha1:base32:$TOKEN sslvpn.ethz.ch
#Same goes here for the password secret file. If you don't want the OTP secret, you can remove the --token- arguments and Variable. You will be prompted for a password, wich is the OTP token.
TOKEN="" #Clears variable for additional security.
}
disconnect () {
sudo killall -v -SIGINT openconnect #add -i option to ask for confirmation, usefull if running multible openconnect.
}
case "$1" in
'connect')
connect
;;
c)
connect
;;
'disconnect')
disconnect
;;
d)
disconnect
;;
dc)
disconnect
;;
*)
echo -e 'Usage: ethz-vpn [Option] \n [Option]: \n connect, c: Connect VPN \n disconnect, d, dc: Disconnect VPN'
esac