“Could not open a connection to your authentication agent” ,ssh-add error even after ssh-agent started

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-01 16:12:21

问题


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.


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/33227125/could-not-open-a-connection-to-your-authentication-agent-ssh-add-error-even-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!