TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

keepalive in ssh?



I've discovered that with port forwarding over ssh I can get access to the
internal web at my work, however I'm trying to figure out how to keep the
connection open.  ssh seems to want to time out every now and then and I want
to be able to restart it, but when I do from cron, things tend to get lost.
Like the connection is there, but when I send traffic over it nothing comes
back.  It only seems to work if I start it from a prompt, ie. not inside
cron.  Here's the shell script I'm running from cron, with names changed to
protect the innocent :)

#! /bin/bash

check=`/bin/ps awx | grep ssh | grep '3128:proxy:3128'`
if [ -z "${check}" ]; then
    /usr/bin/ssh -q -C -f -g -L 3128:proxy:3128 -l username host.company.com 'while `/bin/true`; do sleep 5; done;'
    #echo "Needs restart"
#else
#  echo "still running"
fi

Anyone got any ideas?

-- 
Jon Schewe 
http://eggplant.mtu.net/~jpschewe
schewe@tcfreenet.org