Permissions of ControlMaster directory
The ControlMaster
feature of ssh
allows to use the same channel for multiple ssh
-commands, see e.g. How can I maintain open ssh connection and use it from shell scripts?
To use ControlMaster
, I added these lines to ~/.ssh/config
:
Host example.com
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 5m
When I run ssh example.com
, I get the following error:
$ ssh example.com
bind: No such file or directory
unix_listener: cannot bind to path: /home/peter/.ssh/sockets/[email protected]
To fix this, I can run mkdir ~/.ssh/sockets
:
$ mkdir ~/.ssh/sockets
$ ll ~/.ssh/sockets
total 8
drwxrwxr-x 2 peter peter 4096 Dec 28 17:51 ./
drwx------ 3 peter peter 4096 Dec 28 17:51 ../
As you can see, the directory ~/.ssh/sockets
has permissions rwxrwxr-w
. What should be the permissions of ~/.ssh/sockets
? Should sockets
even be in ~/.ssh
?
Solution 1:
You can put your sockets
directory anywhere you like (as long as you have the appropriate rights to write there) but putting it inside the .ssh
seems to me the more sensible idea (except in some very rare specific cases like I had once: pathname was too long)
Since .ssh
should already be something like drwx------
, the rights of .ssh/sockets
could be the same or more liberal, this will have no impact.
But I do not think this is your problem. Your error message is not consistent with your configuration file. The config file has a @
in the ControlPath
(and it is ok) but in the error message you do not have one.
When testing, make sure first to kill all running ssh
instances to the given host, as some may persist per your configuration and then if you change it you may not get the expected behavior.
PS: please use example.com
when you need a dummy hostname for documentation purposes