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

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