5

I need to add multiple ssh keys , so i need to execute ssh-add

But I get error of Could not open a connection to your authentication agent

I read multiply posts like Could not open a connection to your authentication agent and https://superuser.com/questions/901568/ssh-agent-could-not-open-connection

I had started the ssh-agent by

eval ($ssh-agent -s)

and the output is like : Agent pid 13524

but still get this error:

 $ ssh-add ~/.ssh/id_rsa
 Could not open a connection to your authentication agent.

I also set

git config --global url."https://".insteadOf git://

And I echo some variable and get this:

echo $SSH_AGENT_PID
12340 
echo $SSH_AUTH_SOCK 
/tmp/ssh-ZbRZr10908/agent.10908

PS: I am using Windows 7 and the under company's network.

2 Answers 2

9

I tried a lot of solutions online but nothing worked. I made more research and found that the following commands worked.

  1. sudo ssh-agent bash
  2. ssh-add /home/user/.ssh/id_rsa
Sign up to request clarification or add additional context in comments.

Comments

7

You put the start of agent wrong. It should be:

eval $(ssh-agent -s)

But if that will not help, anyway you can troubleshoot the issue by trying to write env variables:

echo $SSH_AGENT_PID
echo $SSH_AUTH_SOCK

and making sure the socket (path from the second echo) exists and have reasonable ACL's. Also checking if the agent itself runs by the PID.

Edit:

I see you are using windows, so there can be problem with the paths. Fortunately ssh-agent supports argument -a with the path to UNIX-domain socket or address to bind. You should try:

 ssh-agent -a ./agent_socket

or

 ssh-agent -a 127.0.0.1:9999

which should work even on windows.

4 Comments

No use. eval $(ssh-agent -s) -->"Agent pid 12340" echo $SSH_AGENT_PID -->12340 echo $SSH_AUTH_SOCK -->/tmp/ssh-ZbRZr10908/agent.10908
I see you are using windows. Is it under cygwin or how? If not, it is probable, that the path starting with /tmp/ will not work for you.
hmm, I just use gitbash to execute these.
I believe there is problem with the path on windows. You should try to start ssh-agent with argument -a ./agent_socket. It should create the socket in current directory and then ssh-add should be able to connect to this socket ... hopefully. Otherwise you can try to bind some localhost address, which should work for sure: ssh-agent -a 127.0.0.1:9999

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.