nsbin/vpn.sh

112 lines
3.2 KiB
Bash
Raw Normal View History

#!/bin/sh
# 2022-02-10, 10:25, Nico Schottelius
set -e
set -x
case "$1" in
2023-08-30 07:38:13 +00:00
uzh|uzhsplit)
vpnc --no-detach "$1"
;;
uzhvnc)
pkill -f 5999:localhost:5900 || true
ssh -L5999:localhost:5900 -f -N uzh-macmini-ipv4
pass git co master
pass uzh/macmini/vnc-password -c
vncviewer localhost:99
;;
2023-09-14 10:32:07 +00:00
runa)
pass git checkout nico-privat
pass tws/runa/vpn-endpoint > /dev/null
endpoint=$(pass tws/runa/vpn-endpoint)
authgroup=$(pass tws/runa/vpn-authgroup)
vpn_user=$(pass tws/runa/vpn-user)
echo "Use: pass -c tws/runa/vpn-password"
authgroup=UK
authgroup=Malta
2023-09-14 10:32:07 +00:00
sudo openconnect \
--protocol=gp ${endpoint} \
--user ${vpn_user} \
--authgroup=${authgroup} \
2023-09-14 10:54:41 +00:00
--allow-insecure-crypto
2023-09-14 10:32:07 +00:00
;;
2023-08-07 12:06:28 +00:00
tws)
2022-09-14 17:43:59 +00:00
# Ensure we are on the right branch and pass has been unlocked
pass git checkout nico-privat
2023-08-07 12:06:28 +00:00
pass tws/nschottelius1 > /dev/null
2023-08-07 12:10:26 +00:00
if [ "$2" ]; then
authgroup="$2"
else
authgroup=Europe
fi
2022-09-14 17:43:59 +00:00
# Try to input the password directly, revert to non input if it fails
2023-08-07 12:06:28 +00:00
pass tws/nschottelius1 | sudo openconnect --protocol=gp portal.techcorpapps.com \
--allow-insecure-crypto --user nschottelius1 \
--passwd-on-stdin --authgroup=$authgroup || \
sudo openconnect --protocol=gp portal.techcorpapps.com \
--allow-insecure-crypto --user nschottelius1 \
--passwd-on-stdin --authgroup=$authgroup
;;
lx)
cd ~/Nextcloud/luxembourg/nico/
sudo openvpn --config nico.ovpn
;;
2023-08-04 07:20:16 +00:00
server*)
f=/etc/openvpn/${1}.conf
if [ -f "$f" ]; then
2023-08-04 17:50:29 +00:00
sudo modprobe tun
2023-08-04 07:20:16 +00:00
sudo openvpn --config ${f}
else
echo "Config file $f is missing"
exit 1
fi
;;
2023-10-18 12:26:16 +00:00
rmovpn)
sudo openvpn --config ~nico/Nextcloud/rulematch/nico-schottelius.ovpn
;;
2022-12-13 13:59:22 +00:00
rm)
case $(hostname) in
bridge)
sudo wg-quick up rmr1n2
sudo wg-quick up rmr3n2
sudo wg-quick up rmr5n2
;;
nb3)
sudo wg-quick up rmr1n1
sudo wg-quick up rmr3n1
sudo wg-quick up rmr5n1
;;
blind)
sudo wg-quick up rmr2n1
sudo wg-quick up rmr4n1
sudo wg-quick up rmr6n1
;;
2023-01-05 12:42:32 +00:00
mirror2)
sudo wg-quick up rmr2n2
sudo wg-quick up rmr4n2
sudo wg-quick up rmr6n2
;;
2023-07-29 15:14:51 +00:00
sun)
2023-07-20 10:35:01 +00:00
sudo wg-quick up rmr1n3
sudo wg-quick up rmr3n3
sudo wg-quick up rmr5n3
;;
2023-07-29 15:14:51 +00:00
sun2)
2023-07-20 10:35:01 +00:00
sudo wg-quick up rmr2n3
sudo wg-quick up rmr4n3
sudo wg-quick up rmr6n3
;;
2022-12-13 13:59:22 +00:00
*)
echo "Host does not have VPN assigned" >&2
exit 1
;;
esac
;;
*)
2022-12-13 14:03:56 +00:00
echo "$0 lf lx rm"
;;
esac