Persistent SSH Tunnels in Kubuntu

Remco Bloemen

2014-02-27, last updated 2014-05-07

Install OpenSSH

Kubuntu doesn’t come with SSH pre-installed. This is odd for a Linux distribution, since even some of the more minimalist ones come with SSH out of the box. In fact, Ubuntu is the first one I’ve seen that doesn’t.

I can understand it though, Ubuntu is aimed at novices, and SSH is somewhat advanced usage of Linux. It can also leave your system vulnerable if you pick weak passphrases.

The procedure of installing OpenSSH is as simple as

but see the next section.

Install SSH with HPN patches



By default Ubuntu does not use the HPN patches in its distribution. The fault is really with the OpenSSH developers, who should “merge the patches already”!


Disallowing password based logins



NATs and SSH tunnels


Configuring the remote machine

Configuring the local machine


Now from any machine



AutoSSH daemon

description "autossh tunnel"

start on runlevel [2345]
stop on runlevel [!2345]

respawn limit 5 60

exec autossh -M 0 -N -R *:2201: -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -o "StrictHostKeyChecking=no" -o "BatchMode=yes" -i /home/autossh/.ssh/id_ecdsa autossh@
Description=Autossh tunnel

ExecStart=/usr/bin/autossh -M 0 -N -R *:2201: -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -o "StrictHostKeyChecking=no" -o "BatchMode=yes" -i /home/autossh/.ssh/id_ecdsa autossh@