]> code.communitydata.science - nu-vpn-proxy.git/blob - ssh-vpn-proxy
don't run the openconnect script in the background
[nu-vpn-proxy.git] / ssh-vpn-proxy
1 #!/bin/bash
2
3 export OPENSSL_CONF="${HOME}/bin/nu-vpn-proxy/openssl.conf"
4 # this allows for legacy renegotation which seems to be required now
5 SEARCH_PATTERN="ESP tunnel connected; exiting HTTPS mainloop."
6
7 # connects to SSH through openconnect and VPN
8 # for use with ProxyCommand in SSH
9
10 # first run openconnect
11 /sbin/start-stop-daemon --pidfile /tmp/nu-vpn-openconnect.pid -S --startas "${HOME}/bin/nu-vpn-proxy/openconnect_command-ssh.sh"
12 sleep 2
13
14 # kill connection on exit
15 function cleanup {
16   /sbin/start-stop-daemon --stop --pidfile /tmp/nu-vpn-openconnect.pid
17 }
18 trap cleanup EXIT
19
20 tail -f /tmp/nu-globalprotect-saml.log | grep -qe "${SEARCH_PATTERN}"
21
22 if [ $? == 1 ]; then
23     echo "Search terminated without finding the pattern"
24     exit
25 fi
26
27 # redirect traffic (standard input and output) through VPN
28 /bin/nc.openbsd -X 5 -x 127.0.0.1:9052 $1 $2
29

Community Data Science Collective || Want to submit a patch?