Could not open a connection to your authentication agent

Could not open a connection to your authentication agent

In this post I will go through ways to fix the error: connection to the authentication agent. This issue is incredibly irritating when you haven't encountered it before, but the problem is simple, basically the ssh-agent is not running.

We need to ensure that we start the ssh-agent before we use ssh-add. If you are using zsh on Ubuntu or Mac the following should work:

eval `ssh-agent -s`

You could also try the following if the above doesn't work on your system:

Bash

exec ssh-agent bash

Zsh

exec ssh-agent zsh

Fish

exec ssh-agent fish

Another potential fix

This might sound obvious and not really like much help, but, the best fix that I have found, is to shutdown my computer and restart it. Whenever I have restarted my computer after having this issue, it has worked without issue.

If I don't feel like restarting I will use the first command provided. Quick note on this, every time you open a new terminal window/tab you might need to run the above.

Conclusion

This is a very irritating problem, but luckily the fix is simple, and hopefully, it is as simple as switching it off and on.