Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

ssh

gitlab

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.

like image 758
JaskeyLam Avatar asked Dec 05 '22 02:12

JaskeyLam


2 Answers

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
like image 51
Umair Afzal Avatar answered Dec 11 '22 10:12

Umair Afzal


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.

like image 38
Jakuje Avatar answered Dec 11 '22 11:12

Jakuje