Can I make ssh tell me which control file it would use for multiplexing?
Posted
by Ryan Thompson
on Server Fault
See other posts from Server Fault
or by Ryan Thompson
Published on 2010-05-09T17:47:20Z
Indexed on
2010/05/09
18:00 UTC
Read the original article
Hit count: 313
ssh
|multiplexing
I am using the following options in my ~/.ssh/config
in order to enable connection multiplexing:
ControlMaster auto
ControlPath ~/.ssh/control/master-%r@%h:%p
However, this has the annoying problem that the first shell to connect to a particular server must be the last to disconnect, because it is the master connection that all the other connections are using. So if you log out of the master, it appears to just hang. To solve this, I would like to wrap ssh with a script that checks if the control master file exists, and if not, starts a master ssh process in the background. Then it would start a slave ssh session.
In order to accomplish this, my script would have to determine the path to the control file that ssh would use. This would entail parsing the ssh command line options and config files and implementing the logic for determining the ControlPath. Is there any way to just ask ssh what path it would use, so I can check it?
© Server Fault or respective owner