Forrest logo
back to the autossh tool

autossh:tldr:74784

autossh: Fork `autossh` into the background before executing `ssh` and don't open a remote shell.
$ autossh -f -M ${monitor_port} -N "${ssh_command}"
try on your machine

The command "autossh" is a utility that automatically restarts SSH (Secure Shell) sessions and keeps them running even if the network connection is intermittent or drops.

Here is the breakdown of the command:

  • "autossh": This is the command itself, invoking the autossh utility.
  • "-f": This option runs autossh in the background as a daemon.
  • "-M ${monitor_port}": This option sets up a monitoring port. The "${monitor_port}" is a placeholder for the actual port number you will specify.
  • "-N": This option tells SSH to not execute any remote command after connecting. It is often used for port forwarding or when only a secure tunnel is required without executing any remote commands.
  • "${ssh_command}": This is a placeholder for the actual SSH command that you want autossh to establish and maintain a connection for. It could be something like "ssh username@hostname" or any other SSH command that you normally use for connecting to a remote server.

In summary, the given command uses autossh to establish and maintain an SSH connection using the provided "${ssh_command}". With the "-f" option, it runs in the background, and the "-M" option sets up a monitoring port for autossh to detect if the SSH connection drops and automatically restart it.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the autossh tool