Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a field office that uses a dialup connection with a non-public IP given from the ISP.

Dialin is done by GNOME-PPP.

How can we hold an SSH connection (with tunnel) open to a server in the Internet while the computer is connected?

share|improve this question
up vote 1 down vote accepted

autossh is a tool (included in the Ubuntu repositories) which can automatically reconnect a SSH session. It can check via a separate if data is still being transmitted properly and reconnect the tunnel:

Here is a nice How-To:

http://pierre.linux.edu/2010/05/setting-up-a-permanent-ssh-tunnel-between-2-servers/

This can be combined with the daemon tool, to run in background.

Complete solution:

aptitude install autossh daemon

In /usr/local/bin/autossh

#!/bin/bash

AUTOSSH_POLL=600
AUTOSSH_PORT=20000
AUTOSSH_GATETIME=30
AUTOSSH_LOGFILE=autossh.log
AUTOSSH_DEBUG=yes
AUTOSSH_PATH=/usr/bin/ssh

HOST=example.com
USER=tunnel

autossh -M $AUTOSSH_PORT -N -L ... -R ... $USER@$HOST 

Port forwardings have to be added instead of the "...". Actually everything after -M $AUTOSSH_PORT are SSH parameters.

And at the beginning of /etc/rc.local add

daemon -n autossh /usr/local/bin/tunnel 
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .