I have a Makefile with some ssh and rsync commands. All of them are executed without errors, but give the following error message:

Error reading response length from authentication socket.

I don't like enigmatic error messages - do you know what it means and how to fix it?

  • That's the most loose definition of "executes correctly" I've seen ;-) It's also very hard to debug invisible code.
    – Kusalananda
    Dec 31, 2016 at 12:28

1 Answer 1


Most google results for the error message show that this fixes the problem:

eval $(ssh-agent)

The reasons for this error can be several and you'd have to analyze each case to see what's going on.

When ssh-agent starts it sets up two environment variables: SSH_AUTH_SOCK and SSH_AGENT_PID. If you're forwarding your agent from another host the latter will not be set.

SSH_AUTH_SOCK is the "authentication socket" mentioned in the error message.

If you have a local agent (SSH_AGENT_PID is set) it's possible the process died or is unable to write to the socket.

If you have a forwarded agent chances are the remote end closed the socket or the local process is unable to read from the forwarding socket.

There are other possible causes of course, but these are the ones I can think of right now or have encountered myself.

You'll have to diagnose each case, strace and lsof can help with that.

Then again, you could just start a new agent as suggested by everyone else and move on to something more fun ;)

  • Thanks for the explanation! I was able to solve my problem by unsetting the SSH_AUTH_SOCK environment variable.
    – Ed Sabol
    Mar 4, 2021 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .