Forrest logo
back to the autossh tool

autossh:tldr:491a3

autossh: Start an SSH session, restarting when a monitoring port fails to return data.
$ autossh -M ${monitor_port} "${ssh_command}"
try on your machine

The command autossh is a program that automatically restarts SSH sessions and keeps them open, ensuring a reliable and persistent SSH connection. It is typically used in scenarios where you need to maintain a stable SSH tunnel or connection, such as for remote port forwarding.

Here's a breakdown of the command:

  • autossh: This is the actual command that launches and manages the SSH session.
  • -M ${monitor_port}: This option specifies the monitor port to be used. The monitor port is used by autossh to detect if the SSH connection is still active. If the connection is lost, autossh will automatically restart it. ${monitor_port} is a placeholder that needs to be replaced with an actual port number.
  • "${ssh_command}": This is the SSH command that autossh will execute to establish the SSH connection. "${ssh_command}" is another placeholder that should be replaced with the command you want to run to initiate the SSH connection. This could include specifying the remote host, username, and any other SSH options you need.

In summary, this autossh command with the provided options and placeholders is meant to establish a reliable SSH connection by monitoring the specified monitor port and executing the specified SSH command.

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