keeping reverse ssh tunnel alive



Hi,

What's the best way to keep an ssh reverse tunnel alive?
Currently I call on my client (host that establishes the reverse tunnel)
this script every 10minutes:

#!/bin/sh
echo -ne "nameserver 8.8.8.8\nnameserver 8.8.4.4\n" > /etc/resolv.conf
RETVAL=`netstat | grep 'S0106b0487afe2a57'| grep -c 'ssh ESTABLISHED'`
echo "${RETVAL} open tunnel(s)"
if [ "$RETVAL" -lt "1" ]
then
echo "starting reverse ssh tunnel"
`ssh -R 19996:localhost:22 -f -N user@host`
echo "done"
fi

which checkes in netstat if the connection is still listed as established,
if not, reestablish it. But this doesn't seem to work very well. I just now
experienced that a client dropped off. Why is that? How can I improve this?

Thank you!
Ron

--- Posted via news://freenews.netfront.net/ - Complaints to news@xxxxxxxxxxxx ---
.