The problem:

ssh config with ControlPath set to ~/.ssh/master-%r@%h:%p

A third party tool which invokes ssh with a ProxyCommand ssh <proxyhost> --pty=false nc -q0 %h %p

The problem is that the third party tool might invoke ssh with proxy command with ultimate target host and then AGAIN with the same target host ip, but with a different proxy intermediate.


ssh -o ProxyCommand 'ssh proxy1 nc -q0 %h %p'

ssh -o ProxyCommand 'ssh proxy2 nc -q0 %h %p'

If the first command is using Control Master, the second command incorrectly uses ControlPath because is there.

Is there a work around or %proxy I can use in ControlPath value?

Update: one workaround which I have yet to try is to export HOME=somewhere_else the next time I run the tool. I should be able to have an alternate .ssh in that alt HOME

1 Answer 1


Reviewing the ssh_config documentation it doesn't look like there's an easy solution.

I believe you could modify your ControlPath to use %n instead of %h to get the hostname as specified on the command line. You could then create real DNS or /etc/hosts entry aliases for your two machines. Then when you use different names to refer to them you will have different ControlPaths for each host.

The downside to this approach is that if you commonly use different names that point to the same IP each of these connections will not be able to benefit from connection sharing as they would previously have if they used the same IP, regardless of the hostname used to access it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .