Re: How to kill port forwarding ssh when client exits

From: Darren Tucker (
Date: 01/09/05

Date: 09 Jan 2005 04:39:09 GMT

In article <4ZC*>,
Simon Tatham <> wrote:
>Coincidentally, I had a need to do this today, and my solution is
>different again from either of the two so far posted. Here's mine.
[snip solution involving named pipes]


The current version (post-3.9) of OpenSSH has another solution: you can
use the ControlMaster pipe to send commands to a backgrounded ssh.

This would be something like):

$ ssh -f -N -M ~/.ssh/server -L 25:your.mail.server:25 server
[do mail]
$ ssh -S ~/.ssh/server -O exit server

Darren Tucker (dtucker at
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.