I have set up sharing an ssh connection on my local machine fine, but when I try and do this on our CI server it is failing and I cant work out why.
the ~/.ssh/config is
StrictHostKeyChecking=no
Host *
ControlMaster auto
ControlPath ~/.ssh/control:%h:%p:%r
ControlPersist 2h
First connection will fail, but will create the socket, second connection will fail as the socket is stale.
The end of the verbose output from first connection is....
$ ssh -vvvv -N user@domain.co.uk
....
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
....
Authenticated to domain.co.uk ([88.47.112.93]:22).
debug1: setting up multiplex master socket
debug3: muxserver_listen: temporary control path /home/rof/.ssh/control:domain.co.uk:22:user.3HfyjbhRCDHGwnrI
debug2: fd 4 setting O_NONBLOCK
debug3: fd 4 is O_NONBLOCK
debug3: fd 4 is O_NONBLOCK
debug1: channel 0: new [/home/rof/.ssh/control:domain.co.uk:22:user]
debug3: muxserver_listen: mux listener channel 0 fd 4
debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x08
debug1: control_persist_detach: backgrounding master process
debug2: control_persist_detach: background process is 84004
Control socket connect(/home/rof/.ssh/control:domain.co.uk:22:user): Connection refused
Failed to connect to new control master
debug1: forking to background
debug1: Entering interactive session.
debug2: set_control_persist_exit_time: schedule exit in 7200 seconds
If you run it without the -N option the command input just hangs.
any subsequent ssh connections say the socket is stale and unlink it, thus not using a shared connection.
Any ideas?
For anyone else with this issue, this was due to the fact the the CI server we use uses overlayfs
as its filesystem, which doesn't play nice with unix sockets.
To fix this, I saved the socket in virtual memory instead..
ControlPath /var/shm/control:%h:%p:%r