How to install autossh on Linux

Question: I would like to install autossh on [insert your Linux distro]. How can I do that?

autossh is an open-source tool that allows you to monitor an SSH session and restart it automatically should it gets disconnected or stops forwarding traffic. autossh assumes that passwordless SSH login for a destination host is already setup, so that it can restart a broken SSH session without user's involvement.

autossh comes in handy when you want to set up reverse SSH tunnels or mount remote folders over SSH. Essentially in any situation where persistent SSH sessions are required, autossh can be useful.

Here is how to install autossh on various Linux distributions.

Install Autossh on Debian or Ubuntu

autossh is available in base repositories of Debian based systems, so installation is easy.

$ sudo apt-get install autossh

Install Autossh on Fedora

Fedora repositories also carry autossh package. So simply use yum command.

$ sudo yum install autossh

Install Autossh on CentOS or RHEL

For CentOS/RHEL 6 or earlier, enable Repoforge repository first, and then use yum command.

$ sudo yum install autossh

For CentOS/RHEL 7, autossh is no longer available in Repoforge repository. You will need to build it from the source (explained below).

Install Autossh on Arch Linux

$ sudo pacman -S autossh

Compile Autossh from the Source on Debian or Ubuntu

If you would like to try the latest version of autossh, you can build it from the source 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

Compile Autossh from the Source on CentOS, Fedora or RHEL

On CentOS/RHEL 7, autossh is not available as a pre-built package. So you'll need to compile it from the source 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
Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

One thought on “How to install autossh on Linux

Leave a comment

Your email address will not be published. Required fields are marked *