Let's say I have four hosts:
If I ssh from M to D using 'ControlMaster auto', once I close the shell connection the mux connection is kept open for future connections. That is, two processes are running in M:
but the former is killed once I close the shell, and the latter is the one kept open for future connections.
If I sshpass from M to D using 'ControlMaster auto', I get three processes:
and only the mux process survives after the shell is closed, so it can be reused.
If I ssh from M to H using 'ControlMaster auto' and P as the ProxyJump host, then I get four processes:
and again, the first one is killed once I close the shell but the other three are kept running. So that, I can reuse the socket for later usage.
However, if I sshpass from M to H using 'ControlMaster auto' and P as the ProxyJump host, then I also get five processes:
BUT then when I close the remote shell, everyone dies but the mux process to P, and the socket that connects to H disappear. So that, I cannot reuse the previous connection.
This looks like an sshpass bug to me, since ssh seems to work fine when used without sshpass.
A simplified config in this case would be:
Host H
PubkeyAuthentication no
Proxyjump P
Host D
PubkeyAuthentication no
Match host !localhost,*
ControlMaster auto
ControlPath ~/.ssh/sockets/test-%h
ControlPersist 30m