]> code.communitydata.science - nu-vpn-proxy.git/blob - ssh-vpn-proxy
update README-CDSC file to make the new openconnect issue clear
[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
11 # first run openconnect
12 /sbin/start-stop-daemon --pidfile /tmp/nu-vpn-openconnect.pid -S --startas "${HOME}/bin/nu-vpn-proxy/openconnect_command-ssh.sh" &  
13 sleep 2
14
15 # kill connection on exit
16 function cleanup {
17   /sbin/start-stop-daemon --stop --pidfile /tmp/nu-vpn-openconnect.pid
18 }
19 trap cleanup EXIT
20
21 tail -f /tmp/nu-globalprotect-saml.log | grep -qe "${SEARCH_PATTERN}"
22
23 if [ $? == 1 ]; then
24     echo "Search terminated without finding the pattern"
25     exit
26 fi
27
28 # redirect traffic (standard input and output) through VPN
29 /bin/nc.openbsd -X 5 -x 127.0.0.1:9052 $1 $2
30

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