Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.