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

When I start my xsession I setup my SSH tunnel to my VPS.

Here is the script the runs on login:

matt@HY731AA:~$ more dotfiles/ 

ssh-add ~/.ssh/id_rsa
screen -dmS ssh /bin/bash -c ~/dotfiles/keeptunnel.bash

Prompt to enter key and voila terminal closes..

And here is keeptunnel.bash

matt@HY731AA:~$ more dotfiles/keeptunnel.bash 

while [ true ]; 
  do    /usr/bin/ssh lin1tunnels > /home/matt/lin1tunnel.log 2>&1 
  sleep 0.4   

On login it seems everything works, tunnel is setup, however I leave my computer on 24/7 through various suspend/unsuspends etc.. The problem is occasionally the SSH tunnel is down, so I figure its just reconnecting or internet/server is down, however doing a screen -list shows the screened session is (Dead???) and to screen -wipe.

What I cant understand is given the loop in keeptunnels there is no way ppossible that screen should be able to exit? I have ConnectTimeout 8 and ServerAliveInterval 5 in .ssh/config for lin1tunnels however that I doubt is the source of the problem as the screened session is dead.

Ideas of why the screened session is dying?

share|improve this question
up vote 1 down vote accepted

A "dead" screen session usually means that the screen server process has crashed. Do dmesg or /var/log/syslog report any segfaults or out-of-memory errors?

You could replace screen with tmux or dtach, or even remove screen entirely by just using ~/dotfiles/keeptunnel.bash & in your script. fact both scripts can be combined:

ssh-add ~/.ssh/id_rsa
while true; do
    ssh -v -N lin1tunnels
    sleep 0.4
done > ~/lin1tunnel.log 2>&1 &
share|improve this answer

You must log in to answer this question.

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