Most google results for the error message show that this fixes the problem:
eval $(ssh-agent)
ssh-add
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 ;)