aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md43
-rwxr-xr-xproxy-tcp-ssh.sh4
2 files changed, 46 insertions, 1 deletions
diff --git a/README.md b/README.md
index e69de29..e6b11b7 100644
--- a/README.md
+++ b/README.md
@@ -0,0 +1,43 @@
+# Establish persistent ssh tunnels
+
+Establish a persistent TCP tunnel between a local endpoint and a remote server.
+If the connection drops, reconnection attempts are made every 10 seconds.
+
+```
+SYNOPSYS
+ ./proxy-tcp-ssh.sh (-S|--ssh-host) SSHHOST (-t|--tunnel) TUNNELSPEC [OPTIONS]
+DESCRIPTION
+ Spawn TCP tunnels between your computer and a remote SSH server. If the
+ connection fail for some reason, the script will try to re-create the
+ tunnels automatically every TIMEOUT seconds.
+OPTIONS
+ -S,--ssh-host SSHHOST
+ Set the ssh host. SSHHOST can be either the full hostname as you would
+ specify it on the ssh command-line (e.g. [user@]myserver.com or hostname
+ if it is set up in your ssh config).
+
+ -t,--tunnel TUNNELSPEC
+ Specify the ports to tunnel as a comma-separated list of either single
+ ports or port pairs (e.g. -t 443,80:8080 will establish tunnels
+ local:443-remote:443 and local:8080-remote:80). Note that you have to
+ be a privileged user (i.e. a user with the CAP_NET_BIND_SERVICE
+ capability) to be able to bind to ports below 1024.
+
+ -p,--ssh-port SSHPORT /!\ Not implemented
+ Set the ssh remote port if different from the default.
+
+ -H,--host HOST
+ Set the tunnel host. HOST can be either the IP or hostname of the
+ server to tunnel to, as seen from the ssh host. Defaults to localhost.
+
+ -i,--interface IF /!\ Not implemented
+ Specify the local interface to bind to. Defaults to localhost. Setting
+ it to 0.0.0.0 will make the tunnel available to other clients on your
+ network (depending on your firewall rules).
+
+ -f
+ Fork the script to the background.
+
+ -h,--help
+ Print this help and exit.
+```
diff --git a/proxy-tcp-ssh.sh b/proxy-tcp-ssh.sh
index ac30bb4..64be43b 100755
--- a/proxy-tcp-ssh.sh
+++ b/proxy-tcp-ssh.sh
@@ -199,7 +199,7 @@ function start_and_monitor_tunnels() {
# - try again after a timeout if exit code is not 0
# - exit if exit code is 0
# NOTE: for now we just **always** try again after timeout
- local timeout_sec=${1:-10}
+ local timeout_sec=${1:-5}
local ntunnels=${#TUNNEL_PORTS_LOCAL[*]}
@@ -212,6 +212,8 @@ function start_and_monitor_tunnels() {
ssh_tunnel_opt+=("${BIND_IF}:${local_port}:${TUNNEL_HOST}:${remote_port}")
done
+ echo "pid=$$"
+
while true; do
# Try establishing the tunnel
echo -n "Starting tunnel... "