Run, monitor and restart SSH connections. Auto-reconnects to keep port forwarding tunnels up. Accepts all SSH flags. More information: https://www.harding.motd.ca/autossh.
autossh -M monitor_port "ssh_command"
autossh -M monitor_port -L local_port:localhost:remote_port user@host
autossh
into the background before executing SSH and do [N]ot open a remote shell:autossh -f -M monitor_port -N "ssh_command"
autossh -f -M 0 -N -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" "ssh_command"
autossh -f -M 0 -N -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -o ExitOnForwardFailure=yes -L local_port:localhost:remote_port user@host
autossh
debug output and SSH verbose output to files:AUTOSSH_DEBUG=1 AUTOSSH_LOGFILE=path/to/autossh_log_file.log autossh -f -M monitor_port -v -E path/to/ssh_log_file.log ssh_command