How does autossh keep the SSH connection alive?

How does autossh keep the SSH connection alive?

ServerAliveInterval and ServerAliveCountMax – they cause the SSH client to send traffic through the encrypted link to the server. This will keep the connection alive when there is no other activity and also when it does not receive any alive data, it will tell AutoSSH that the connection is broken and AutoSSH will then restart the connection.

What was the original idea of auto SSH?

The original idea and the mechanism were from rstunnel (Reliable SSH Tunnel). With version 1.2 of autossh the method changed: autossh uses ssh to construct a loop of ssh forwardings (one from local to remote, one from remote to local), and then sends test data that it expects to get back.

Is there a way to start auto SSH tunnel?

If you recall all the ssh options we had used already, we can now simply start the autossh tunnel like so: AutoSSH can also be controlled via a couple of environmental variables. Those are useful if you want to run AutoSSH unattended via cron, using shell scripts or during boot time with the help of systemd services.

What do you need to know about autossh?

Autossh is a program to start a copy of ssh and monitor it, restarting it as necessary should it die or stop passing traffic.

How can I impersonate the user of autossh?

(you must use su with the first command to impersonate the user autossh as this has not a shell or a valid password). Once this is done you should take care to copy the public key on the machine/s and/or destination and install it in the user’s home of autossh in the file .ssh /authorized_keys ; check that this file belongs to the user autossh .

How to create a SSH tunnel with autossh?

Once this is done you can create a tunnel just by running the opportune command on ssh through autossh . Since you only want to bring up the tunnel you need to use the option -N to tell ssh to not run any commands, the option -f to put it in the background, and these options are also important: