Where developers come to connect, share, build and be inspired.


Fix "Could not open a connection to your authentication agent." when using ssh-add


If you're trying to add identities to the authentication agent using ssh-add you might get the following error:

Could not open a connection to your authentication agent.

The reason as the error message suggests is, ssh-add doesn't know how to talk with the authentication agent.

The problem can be solved by setting SSH_AUTH_SOCK environment variable.

If you run ssh-agent you should get some output like this:

SSH_AUTH_SOCK=/tmp/ssh-agVZL13989/agent.13989; export SSH_AUTH_SOCK;
echo Agent pid 13990;

now if you evaluate the command output in your shell, the variable will be set:

eval $(ssh-agent)

Hope it helps.


  • 7d4229521454ea7649c082da6115d456

    Thanks! But I don't understand why I have to execute it every time...Is there any work-around?

  • David_michael_welch

    @crissdev: Add the eval $(ssh-agent) line to your ~/.bash_profile ( https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html ).

    If you are using a shell other than bash, there are analogous user-specific config files.


  • 9b3197f94529a9a00c00f04ef09d0160

    Yes, It work thanks!

  • Nf2imfva_normal

    Finally got it working thanks to this post!!

    Thank you a bunch :) it was so easy after all. Going back to playing with Heroku

    TinyTiger from http://www.liki-tiki.com

  • Ads_z_normal

    thanks, it helped.

  • User-avatar

    it work perfectly for me, thanks

  • 4cb779d2c63f361f195f922feebee31e_normal

    thank you very much, I have been having this issue for the past few months. Every time I run composer update on my site instance I get asked to enter passphrase like a million times.....this post solved that issue!!

  • User-avatar

    thanks so much.. so much time wasted trying to figure this out.

  • Tkh-kjnu_normal

    Thank you very very much!

  • None

    Thanks a lot, that solved it ! :D

  • None

    Thanks.. Works like a charm..

  • None

    thank you. I was trying to follow github's tutorial to create SSH keys, and they seem to have forgotten about the "eval" part.

  • None

    I am sorry to say that it doesn't work for me! What's the reason?

  • None

    Worked..thank you!!

Add a comment