Share first ssh connection to user@host opportunisitically using ControlMaster
Solution 1:
From the ssh_config
man page:
ControlMaster
...
Two additional options allow for opportunistic multiplexing: try
to use a master connection but fall back to creating a new one if
one does not already exist. These options are: “auto” and
“autoask”. The latter requires confirmation like the “ask”
option.
So if you configure ssh with ControlMaster auto
, it will attempt to connect to use an existing SSH session, falling back to creating a new master connection if that fails.
So a configuration like the following is probably what you're after:
ControlMaster auto
ControlPath ~/.ssh/control/%r@%h:%p