2016-01-08 07:41:27 +03:00
|
|
|
# autossh
|
|
|
|
|
|
|
|
> Runs, monitors and restarts SSH connections.
|
|
|
|
> Auto-reconnects to keep port forwarding tunnels up. Accepts all ssh flags.
|
|
|
|
|
2016-01-13 14:04:46 +03:00
|
|
|
- Open an SSH session, restarting when a monitoring port fails return data:
|
2016-01-08 07:41:27 +03:00
|
|
|
|
|
|
|
`autossh -M {{monitor_port}} {{ssh_command}}`
|
|
|
|
|
2016-01-13 14:04:46 +03:00
|
|
|
- Open an SSH session which forwards a local port to a remote one, restarting if necessary:
|
2016-01-08 07:41:27 +03:00
|
|
|
|
|
|
|
`autossh -M {{monitor_port}} -L {{local_port}}:localhost:{{remote_port}} {{user}}@{{host}}`
|
|
|
|
|
2016-01-13 14:04:46 +03:00
|
|
|
- Fork before executing ssh (runs in the background) and don't open a remote shell:
|
2016-01-08 07:41:27 +03:00
|
|
|
|
|
|
|
`autossh -f -M {{monitor_port}} -N {{ssh_command}}`
|
|
|
|
|
2016-01-13 17:26:38 +03:00
|
|
|
- Run autossh in the background, with no monitoring port, instead relying on SSH keep-alives every 10 seconds to detect failure:
|
2016-01-08 07:41:27 +03:00
|
|
|
|
|
|
|
`autossh -f -M 0 -N -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" {{ssh_command}}`
|
|
|
|
|
2016-01-13 14:04:46 +03:00
|
|
|
- Run autossh in the background, with no monitoring port, no remote shell, exiting if the port forward fails:
|
2016-01-08 07:41:27 +03:00
|
|
|
|
|
|
|
`autossh -f -M 0 -N -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -o ExitOnForwardFailure=yes -L {{local_port}}:localhost:{{remote_port}} {{user}}@{{host}}`
|
|
|
|
|
2016-01-13 17:26:38 +03:00
|
|
|
- Run autossh in the background with debug output logged to a file and ssh verbose output logged to a second file:
|
2016-01-08 07:41:27 +03:00
|
|
|
|
2016-07-22 23:24:06 +03:00
|
|
|
`AUTOSSH_DEBUG=1 AUTOSSH_LOGFILE={{log_file}} autossh -f -M {{monitor_port}} -v -E {{ssh_log_file}} {{ssh_command}}`
|