]> code.communitydata.science - nu-vpn-proxy.git/blobdiff - ssh-vpn-proxy
initial version of the CDSC version of scripts
[nu-vpn-proxy.git] / ssh-vpn-proxy
diff --git a/ssh-vpn-proxy b/ssh-vpn-proxy
new file mode 100755 (executable)
index 0000000..3548b40
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash 
+
+SEARCH_PATTERN="ESP tunnel connected; exiting HTTPS mainloop."
+
+# connects to SSH through openconnect and VPN
+# for use with ProxyCommand in SSH
+
+
+# first run openconnect
+/sbin/start-stop-daemon --pidfile /tmp/nu-vpn-openconnect.pid -S --startas "$HOME/bin/nu-vpn-proxy/openconnect_command-ssh.sh" &  
+sleep 2
+
+# kill connection on exit
+function cleanup {
+  /sbin/start-stop-daemon --stop --pidfile /tmp/nu-vpn-openconnect.pid
+}
+trap cleanup EXIT
+
+tail -f /tmp/nu-globalprotect-saml.log | grep -qe "${SEARCH_PATTERN}"
+
+if [ $? == 1 ]; then
+    echo "Search terminated without finding the pattern"
+    exit
+fi
+
+# redirect traffic (standard input and output) through VPN
+/bin/nc.openbsd -X 5 -x 127.0.0.1:9052 $1 $2
+

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