I've been having my (unused interactive) ssh shells closed after a
timeout, on some servers. Seeing as I'm often opening tunnels with
these, that's a curse.

So my first response was to run a little shell script to repeatedly
sleep and produce some output ... which works OK.

But then I occasionally wanted to do some interactive stuff on the
server, and rather than log in again, or interrupt my script (and
possibly forget to restart it) I remembered a shell timeout feature (I
think originally from ksh, but definately in bash now) ...

The script (called 30m :-)
#!/bin/bash
while :
do
 date
 echo "To terminate, drop the ssh connection (return tilde dot)"
 TMOUT=1800 bash
done

The invocation from the desktop machine :-
$ ssh -t _hostname_ /path/to/30m

This gives me an interactive shell, that will automatically time-out,
exit, and be restarted every 1800 seconds (30 minutes), thus keeping the
tunnel open, avoiding the ssh timeout, and presenting me with a shell.

Ths only problem would be that any shell environment I have would be
lost when the shell times out ...

-jim

Reply via email to