I am looking for an option for OpenSSH on Linux to insist on using pre-existing control master connection. That is, I would like to make sure that that an ssh command fails if it cannot connect to the master connection socket and never tries to connect to the remote host itself.
I tried different combinations of ControlPath and ControlMaster, but it seems that ssh, when the master socket is not available, will try to connect in any case.
As a workaround I put in my ~/.ssh/config:
Match host my-master-only-host
# Use non-existing port to insist on using master connection
Port 55555
so by default ssh fails and then switch to the real port when starting the master connection:
ssh -p 22 -M my-master-only-host
This works, but depending on firewall settings ssh without master may take a while until the connection timeouts. Any better way?