SSH "Control socket connect(PATH)": what it means
A line that starts with Control socket connect( and names a path
is about a file on your own machine. ssh tried to connect to the control
socket at that path, to share an existing connection, and the connect failed.
It is not a message from the SSH server, and it says nothing about port 22.
This page describes standard OpenSSH behaviour. The commands are the usual ones, and wording, the reason after the colon and the way ssh handles a leftover socket differ between versions and platforms. We did not run them on your system for this page.
What the line looks like
Control socket connect(/home/you/.ssh/cm-you@server.example.com:22): Connection refused
The form is Control socket connect(PATH): REASON. The path is
only an example, since its folder and file name come from your config. The
words after the colon are the reason the system gave for the failed connect.
Connection refused is a usual one, and others are possible. They
can differ between platforms and versions, so this page does not list them.
Connection sharing, often called multiplexing, lets later ssh commands ride on
one connection that an earlier command, the master, already opened. The master
listens on a Unix socket at the path set by ControlPath, and the
later commands connect to it. This line means a command tried to do that and
could not connect. A common reason is that nothing is listening at the path
any more, for example when the master ended and left its socket file behind,
but the line does not say so.
Connection refused here does not mean the SSH server refused a
TCP login. The word comes from the local socket, and no network connection was
tried.
You can see this line in two ways. In some versions and cases, a normal
command that finds a stale socket may print it before carrying on or giving
up. It is also printed as a fatal error when the command is not a normal
session open, for example ssh -O check or
ssh -O exit, which only talk to a running master. A missing
socket on a normal new session may only appear as a debug line, not as this
one. Some versions also remove a stale socket in some cases and only note it
in the debug output, so what you see depends on your version.
Which page is this?
Several lines sound alike, so check the text. This page is for the connect line with a path in it.
-
ControlSocket already exists
is the opposite problem: a file was already at the path ssh wanted to create
its own socket, so it gave up being the master. That page also covers the
unix_listenerline withAddress already in use, how to find the path, and how to start fresh or clear a leftover socket. - ssh: connect to host ... Connection refused names a host and a port, and means the SSH server port refused the TCP connection. This page names a file path and never reaches the network.
- Connection closed by remote host and Timeout, server not responding are about a session that was already open and then ended.
-
Address already in use on a local forward
is a line that starts with
bindand names a TCP port for a forward, not a socket file.
1. Read the path in the line
The path inside the brackets is the file ssh tried to connect to. Look at it:
ls -l /home/you/.ssh/cm-you@server.example.com:22
Use your own path. On most systems a socket shows s as the first
character of the listing. A socket file can be there with nothing behind it,
which is the usual shape of a leftover. If the file is not there, a master may
have just ended. The
ssh -v output reader can check a pasted log
for this line. It runs in your browser and sends nothing.
2. Compare it with the settings in use
Check that the path is the one your config or command meant, and whether this
host is set to create or reuse a master. The
mux page shows how to
read ControlPath and ControlMaster with
ssh -G, so this page does not repeat it. A path can come from a
Host block, a wildcard block, or -o and
-S on the command line, and the value ssh -G prints
is the one in effect.
3. See whether a master is running
With the same host name and settings as the original command, ask for the master's state:
ssh -O check myserver
If it reports a running master, the socket is live and something else is the
matter, such as a different user or a path that does not match. If it prints
the same Control socket connect line, nothing is answering at
that path. A leftover file is one possible reason, and a path that does not
match the settings in use is another. Here the line comes from
-O and not from a normal session. The wording of the check's own
output differs between versions.
To open a session without sharing while you sort it out, and to start fresh or clear a leftover socket, follow the steps on the ControlSocket already exists page. Check what still uses a master before ending it, since that can cut sessions and forwards riding on it.
If the machine is a RescueShell device
Reaching a device through RescueShell does not depend on a control socket or on a multiplexed SSH session that you hold open yourself. The agent on the device keeps an outbound HTTPS connection to our relay, so reaching a shell does not need an inbound port on the device. See SSH behind a firewall without port forwarding. That needs the agent installed and running first.
This line is about a local control socket that could not be connected to. The relay does not create or repair that socket, and clearing one on your computer changes nothing on a device. If a shell does not open once the agent is installed, see the shell does not open.
Try it on one device
The first device is free to try with no card, for 30 days from when it connects, not from when you sign up. Start a trial.