My take on this is something like:
 
#!/bin/bash
echo $$ > /var/run/sshpf-persitent.pid
cat > ~/.ssh/config << EOF
Host *
 Protocol 2
 ServerAliveCountMax 3
 ServerAliveInterval 120
 ExitOnForwardFailure yes 
EOF
sshpf ()
{
 ssh -M -S /tmp/3306.port.forwarding -o ControlPersist=yes -L 
3306:localhost:3306 -N -f p...@jumphost
}

sshpf
 
while:
do
 if ssh -o ConnectionTimeout=1 p...@jumphost exit > /dev/null 2>&1; then
  sleep 120
 else
  killall ssh
  sshpf
 fi
done
exit 0

 
Though, it will require SSH v2 and Openssh 5.6 if you like to use 
'ControlPersist'.

--
Greek Ordono 
myppa: launchpad.net/~grexk/+archive/ppa

--- On Thu, 10/21/10, eric pareja <[email protected]> wrote:


From: eric pareja <[email protected]>
Subject: Re: [plug] SSH port forwarding to encrypt database connection
To: "Philippine Linux Users' Group (PLUG) Technical Discussion List" 
<[email protected]>
Date: Thursday, 21 October, 2010, 11:56 AM


of course using GNU screen helps the session last even longer. ctrl-a
d lang ang katapat.

On Thu, Oct 21, 2010 at 8:48 AM, kagoryu <[email protected]> wrote:
>  how about using screen for the sessions?
>
> On 10/21/2010 7:36 AM, eric pareja wrote:
>> SSH connections can survive disconnects/reconnects provided the IP
>> addresses involved remain the same. The timeout before an SSH
>> connection closes is long enough that I've been able to do dial-up PPP
>> connection to a host, start an SSH session, disconnect dial-up PPP
>> link for>10 minutes, reconnect dial-up PPP (same IP as earlier) and
>> the SSH session continues where it left off.
>>
>> On Thu, Oct 21, 2010 at 5:04 AM, Bopolissimus Platypus Jr
>> <[email protected]>  wrote:
>>
>>> ssh connects via TCP and when the underlying internet connection goes
>>> down, the ssh process will exit and any connections tunnelled over
>>> that ssh connection will also go down.  so all of those connections
>>> will need to be reconnected.
>
> _________________________________________________
> Philippine Linux Users' Group (PLUG) Mailing List
> http://lists.linux.org.ph/mailman/listinfo/plug
> Searchable Archives: http://archives.free.net.ph
>



-- 
Eric Manuel Pareja ([email protected]) LPIC-2, NCLP | PGP/GPG Key 0xB82E42D9
Coordinator for Technology - National Telehealth Center
University of the Philippines Manila
Senior Linux Trainer - International Open Source Network - ASEAN+3
Ang mundo ay aklat, at iisang pahina lamang ang nababasa ng hindi naglalakbay.
 - San Agustin
わかよたれぞ つねならむ
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph

_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph

Reply via email to