Autossh is an open source tool that can help manage SSH sessions, automatically connect and stop forwarding traffic. Autossh will assume that the target host has set up a password-free SSH login so that autossh can connect to the disconnected SSH session without user action.
As long as you build a reverse SSH tunnel or mount an SSH-based remote folder, AUTOSSH will come in handy sooner or later. Basically, Autossh is certainly useful as long as you need to maintain an SSH session.
There are many installation methods for Linux distribution autossh below.
Debian or Ubuntu Systems
Autossh has joined the base library based on the Debian system, so it can be easily installed.
The code is as follows:
$ sudo apt-get install Autossh
Fedora system
The Fedora Library also contains autossh packages, which are installed using Yum.
The code is as follows:
$ sudo yum install Autossh
CentOS or RHEL system
Centos/rhel 6 or earlier, you need to open the third library Repoforge library before you can use Yum installation.
The code is as follows:
$ sudo yum install Autossh
After Centos/rhel 7, Autossh is no longer in the Repoforge library. You need to compile the installation from the source code (example below).
Arch Linux System
The code is as follows:
$ sudo pacman-s autossh
Compile and install from source code in Debian or Ubuntu systems
If you want to use the latest version of AUTOSSH, you can compile your own source installation
The code is as follows:
$ sudo apt-get install gcc make
$ wget http://www.harding.motd.ca/autossh/autossh-1.4e.tgz
$ TAR-XF autossh-1.4e.tgz
$ CD autossh-1.4e
$./configure
$ make
$ sudo make install
Install from source code in CentOS, Fedora or RHEL system
After Centos/rhel 7, Autossh is not a precompiled package. So you have to compile the installation from the source code.
The code is as follows:
$ sudo yum install wget gcc make
$ wget http://www.harding.motd.ca/autossh/autossh-1.4e.tgz
$ TAR-XF autossh-1.4e.tgz
$ CD autossh-1.4e
$./configure
$ make
$ sudo make install