[Gllug] Killing ssh tunnels

Matthew Kirkwood matthew at hairy.beasts.org
Thu Aug 22 14:53:46 UTC 2002


On Thu, 22 Aug 2002, Jonathan Dye wrote:

> I have got mutt to set up an ssh tunnel to a mailserver using the
> imap_preconnect option.  This starts ssh in the background so that
> when I exit mutt the tunnel is still around. What I would like to do
> is have a logout script (or something) that kills the ssh when I close
> the terminal.  But, I don't want closing a different terminal to kill
> off the ssh tunnel.  Can anyone suggest a way I can do this?

In .bash_profile:

ssh -f -L foo:bar:baz mailhost
SSH_TUNNEL_PID=$1

In .bash_logoout:

[ "$SSH_TUNNEL_PID" ] && kill $SSH_TUNNEL_PID

might do it.

Matthew.


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list