From f3a144b830dc4eb2d2bbf343fa3dc0da2bbb26a5 Mon Sep 17 00:00:00 2001 From: Peter Tripp Date: Thu, 7 Jan 2016 20:41:27 -0800 Subject: [PATCH] Perhaps human readable autossh examples. --- pages/common/autossh.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pages/common/autossh.md diff --git a/pages/common/autossh.md b/pages/common/autossh.md new file mode 100644 index 000000000..bd30b4ea5 --- /dev/null +++ b/pages/common/autossh.md @@ -0,0 +1,28 @@ +# autossh + +> Runs, monitors and restarts SSH connections. +> Auto-reconnects to keep port forwarding tunnels up. Accepts all ssh flags. + +- Open an SSH session, restarting when a monitoring port fails return data. + +`autossh -M {{monitor_port}} {{ssh_command}}` + +- Open an SSH session which forwards a local port to a remote one, restarting if necessary. + +`autossh -M {{monitor_port}} -L {{local_port}}:localhost:{{remote_port}} {{user}}@{{host}}` + +- Fork before executing ssh (runs in the background) and don't open a remote shell. + +`autossh -f -M {{monitor_port}} -N {{ssh_command}}` + +- Run autossh in the background, with no monitoring port instead relying on SSH keep-alives every 10secs to detect failure. + +`autossh -f -M 0 -N -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" {{ssh_command}}` + +- Run autossh in the background, with no monitoring port, no remote shell, exiting if the port forward fails. + +`autossh -f -M 0 -N -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -o ExitOnForwardFailure=yes -L {{local_port}}:localhost:{{remote_port}} {{user}}@{{host}}` + +- Run autossh in the background with debug output logged to a file, ssh verbose output logged to a second file. + +`AUTOSSH_DEBUG=1 AUTOSSH_LOGFILE={{log_file}} autossh -f -M {{monitor_port}} -v -E {{ssh_logfile}} {{ssh_command}}`