Git Bash: Failed to open connection with your authentication agent.

I'm new to Github, and Generating SSH Keys look necessary. And my boss reported this, so I need to follow through.

I have successfully created an SSH key, but when I am going to add it to ssh-agent

that's what happens

What is the problem?

enter image description here

+79
git github
Jun 11 '14 at 4:44
source share
8 answers

It seems you need to run ssh-agent before using it:

 eval `ssh-agent -s` 

This question was answered in this section: Failed to open connection with your authentication agent

+140
Jun 11 '14 at 6:53
source share

I checked all the solutions on this post and the post mentioned above, and I did not find a solution that worked for me.

I am using Git 1.9.5 Preview in Windows 7 with the following configuration: - Run Git from the Windows command line - Place a Windows-style checkout, commit a Unix-style line ending

I used the Git Bash 'console for everyone ... And everything was fine until I tried to set the SSH keys. The GitHub documentation says that you need to do the following (do not run these commands until you finish reading the message):

Make sure ssh-agent is enabled:

If you are using Git Bash, enable ssh-agent:
 # start the ssh-agent in the background ssh-agent -s # Agent pid 59566 
If you are using another terminal prompt, such as msysgit, enable ssh-agent:
 # start the ssh-agent in the background eval $(ssh-agent -s) # Agent pid 59566 

Now, of course, I missed the fact that you had to do one or the other. Thus, I ran these commands several times because the ssh-add command did not execute, so I went back to this step and kept repeating again and again.

The result is a single Windows ssh-agent process that is created each time you run these commands (pay attention to the new PID every time you enter these commands?)

So, Ctrl + Alt + Del and click End Process to stop the ssh-agent.exe process .

Now that all the spoiled things from failed attempts will be cleared, I will tell you how to make it work ...

In the ' Git Bash ':

Run the ssh-agent.exe process

 eval $(ssh-agent -s) 

And set the SSH keys

 ssh-add "C:\Users\MyName\.ssh\id_rsa" 

* Adjust the path above with your username and make sure the directory location * /. ssh is in the right place. I think you selected this place during the installation of Git? Maybe not ...

The part I did wrong before I realized this was not using quotes around the ssh-add location. The above describes how to enter it in Windows.

+39
Jun 24 '15 at 4:29
source share

On Windows, you can use Startup with one of the following commands.

For 32-bit:

"C: \ Program Files (x86) \ Git \ cmd \ start-ssh-agent.cmd"

For-64 Bit:

"C: \ Program Files \ Git \ cmd \ start-ssh-agent.cmd"

+20
Nov 13 '15 at 16:22
source share

Situation: MVS2017 application - Using Git Bash on Windows 10 - Attempting to connect to BitBucket storage.

For clarity, when you install Git for Windows ( https://git-scm.com/download/win ), it comes with the Git Bash utility.

enter image description here

So, I am in "Git Bash" as follows:

 Mike@DUBLIN MINGW64 ~/source/repos/DoubleIrish (master) $ git remote add origin git@bitbucket.org:Guiness/DoubleIrish.git $ git remote -v origin git@bitbucket.org:Guiness/DoubleIrish.git (fetch) origin git@bitbucket.org:Guiness/DoubleIrish.git (push) Mike@DUBLIN MINGW64 ~/source/repos/DoubleIrish (master) $ git push -u origin master [...] git@bitbucket.org: Permission denied (publickey). fatal: Could not read from remote repository. 

Is the private key configured?

 $ ssh -V OpenSSH_7.7p1, OpenSSL 1.0.2p 14 Aug 2018 $ ls -a ~/.ssh ./ ../ known_hosts 

I see that at the moment my private key file ( id_rsa ) is missing. So I add this: (note: creating a pair of private and public keys is beyond the scope of my answer, but I can say that on Linux you can use ssh-keygen for this.)

 $ ls -a ~/.ssh ./ ../ id_rsa known_hosts 

OK, let's continue:

 $ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-KhQwFLAgWGYC/agent.18320; export SSH_AUTH_SOCK; SSH_AGENT_PID=17996; export SSH_AGENT_PID; echo Agent pid 17996; $ ssh-add ~/.ssh/id_rsa Could not open a connection to your authentication agent. 

To solve this problem, I run:

 $ ssh-agent bash 

And then again:

 $ ssh-add ~/.ssh/id_rsa Identity added: /c/Users/Mike.CORP/.ssh/id_rsa (/c/Users/Mike.CORP/.ssh/id_rsa) 

It worked for me. Hope this helps

+6
Oct 21 '18 at 20:04
source share

I also struggled with the problem.

After entering $ eval 'ssh-agent -s' followed by $ ssh-add ~ / .ssh / id_rsa

I received the same complaint: "Could not open connection with your authentication agent." Then I understand that there are two different quotes on my computer keyboard. So I tried the same position as "~": $ eval ssh-agent -s $ ssh-add ~ / .ssh / id_rsa

And it sounds like that.

+2
Jan 24 '16 at 23:47
source share

I would like to improve the accepted answer

Disadvantages of using .bashrc with eval ssh-agent -s :

  1. Each git-bash will have its own ssh-agent.exe process.
  2. SSH key must be added manually every time you open git-bash

Here is my .bashrc that will eradicate all the flaws

Put this .bashrc in your home directory (Windows 10: C:\Users\[username]\.bashrc ) and it will be executed every time a new git-bash is opened and ssh-add will work as a first-class citizen

Read #comments to understand how it works.

 # Env vars used # SSH_AUTH_SOCK - ssh-agent socket, should be set for ssh-add or git to be able to connect # SSH_AGENT_PID - ssh-agent process id, should be set in order to check that it is running # SSH_AGENT_ENV - env file path to share variable between instances of git-bash SSH_AGENT_ENV=~/ssh-agent.env # import env file and supress error message if it does not exist . $SSH_AGENT_ENV 2> /dev/null # if we know that ssh-agent was launched before ($SSH_AGENT_PID is set) and process with that pid is running if [ -n "$SSH_AGENT_PID" ] && ps -p $SSH_AGENT_PID > /dev/null then # we don't need to do anything, ssh-add and git will properly connect since we've imported env variables required echo "Connected to ssh-agent" else # start ssh-agent and save required vars for sharing in $SSH_AGENT_ENV file eval $(ssh-agent) > /dev/null echo export SSH_AUTH_SOCK=\"$SSH_AUTH_SOCK\" > $SSH_AGENT_ENV echo export SSH_AGENT_PID=$SSH_AGENT_PID >> $SSH_AGENT_ENV echo "Started ssh-agent" fi 

Also in this scenario, a little trick is used to ensure that the provided environment variables are shared by git-bash instances, storing them in an .env file.

+1
May 02 '19 at 16:02
source share

Try using cygwin instead of bash. it worked for me

0
Jul 11 '19 at 2:15
source share

The above solution does not work for me for an unknown reason. below is my labor solution that worked successfully.

1) DO NOT generate a new ssh key using the ssh-keygen -t rsa -C"xxx@xx.com" , you can delete existing SSH keys.

2), but use the Git GUI, → "Help" → "Show ssh key" → "Generate key", the key will be automatically saved in ssh and you will no longer need to use ssh-add .

-one
Jul 08 '16 at 5:36
source share



All Articles