Git Bash: Could not open a connection to your authentication agent
- leipz
- 2014-06-11 04:44
- 8
I'm new to Github and Generating SSH Keys look a neccessity. And was informed by my boss about this, so I need to comply.
I successfully created SSH Key but when I'm going to add it to the ssh-agent
this is what happens
What seems to be the problem?
8 Answers
I checked all the solutions on this post and the post that @kenorb referenced above, and I did not find any solution that worked for me.
I am using Git 1.9.5 Preview on Windows 7 with the following configuration: - Run Git from the Windows Command Prompt - Checkout Windows-style, commit Unix-style line endings
I used the 'Git Bash' console for everything... And all was well until I tried to install the SSH keys. GitHub's documentation says to do the following (don't run these commands until you finish reading the post):
Ensure ssh-agent is enabled:
If you are using Git Bash, turn on ssh-agent:# start the ssh-agent in the background ssh-agent -s # Agent pid 59566If you are using another terminal prompt, such as msysgit, turn on 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 were supposed to do one or the other. So, I ran these commands multiple times because the later ssh-add
command was failing, so I returned to this step, and continued to retry over and over.
This results in 1 Windows 'ssh-agent' process being created every single time you run these commands (notice the new PID every time you enter those commands?)
So, Ctrl
+Alt
+Del
and hit End Process
to stop each 'ssh-agent.exe' process.
Now that all the messed up stuff from the failed attempts is cleaned up, I will tell you how to get it working...
In 'Git Bash':
Start the 'ssh-agent.exe' process
eval $(ssh-agent -s)
And install the SSH keys
ssh-add "C:\Users\MyName\.ssh\id_rsa"
* Adjust the path above with your username, and make sure that the location of the* /.ssh directory is in the correct place. I think you choose this location during the Git installation? Maybe not...
The part I was doing wrong before I figured this out was I was not using quotes around the 'ssh-add' location. The above is how it needs to be entered on Windows.
could not open a connection to your authentication agent bashrc, Could not open a connection to your authentication agent. To resolve this error: bash: $ eval `ssh-agent -s` tcsh: $ eval `ssh-agent -c` Then use ssh-add as you normally would. Could not open a connection to your authentication agent. To resolve this error: bash: $ eval `ssh-agent -s` tcsh: $ eval `ssh-agent -c` Then use ssh-add as you normally would.
derekmx271
2015-06-26 23:23
On Windows, you can use Run with one of the below 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"
could not open a connection to your authentication agent fish shell, SSH_AUTH_SOCK not set. You can also encounter this situation when SSH_AUTH_SOCK variable is not set and hence the ssh-add cannot contact an authentication agent. Verify first that ssh-agent is running on your system by running a command. $ ssh-agent. You should see similar output. SSH_AUTH_SOCK not set. You can also encounter this situation when SSH_AUTH_SOCK variable is not set and hence the ssh-add cannot contact an authentication agent. Verify first that ssh-agent is running on your system by running a command. $ ssh-agent. You should see similar output.
Jhourlad Estrella
2018-01-17 02:26
Situation: MVS2017 App - Using 'Git Bash' on Windows 10 - Trying to connect to a BitBucket repository.
To be clear, when you install Git for Windows (https://git-scm.com/download/win), it comes with an utility called Git Bash.
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 set up?
$ ssh -V OpenSSH_7.7p1, OpenSSL 1.0.2p 14 Aug 2018 $ ls -a ~/.ssh ./ ../ known_hosts
I can see that, at this point, my private key file (id_rsa
) is missing. So I add it: (note: generating a pair of private-public keys is out of scope of my reply, but I can say that in Linux, you can use ssh-keygen
for that.)
$ ls -a ~/.ssh ./ ../ id_rsa known_hosts
OK, let's proceed:
$ 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, 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
bitbucket ssh could not open a connection to your authentication agent, Double-click the Pageant (PuTTY Authentication Agent) icon in your system tray to open the Pageant Key List dialog. If you don't see your SSH key, click Add Key. Could not open a connection to your authentication agent You may see this error when trying to use the ssh-add command. Double-click the Pageant (PuTTY Authentication Agent) icon in your system tray to open the Pageant Key List dialog. If you don't see your SSH key, click Add Key. Could not open a connection to your authentication agent You may see this error when trying to use the ssh-add command.
Varus Septimus
2018-10-21 20:04
I was struggling with the problem as well.
After I typed $ eval 'ssh-agent -s' followed by $ssh-add ~/.ssh/id_rsa
I got the same complain: "Could not open a connection to your authentication agent". Then I realize there are two different kind of quotation on my computer's keyboard. So I tried the one at the same position as "~": $ eval ssh-agent -s
$ ssh-add ~/.ssh/id_rsa
And bang it worked.
linux authentication agent, ssh-agent is a program to hold private keys used for public key authentication (RSA, DSA). The idea is that ssh-agent is started in the beginning of an X-session or a login session, and all other windows or programs are started as clients to the ssh-agent program. ssh-agent is a program to hold private keys used for public key authentication (RSA, DSA). The idea is that ssh-agent is started in the beginning of an X-session or a login session, and all other windows or programs are started as clients to the ssh-agent program.
Avi
2016-01-24 23:47
I would like to improve on the accepted answer
Downsides of using .bashrc
with eval ssh-agent -s
:
- Every git-bash will have it's own ssh-agent.exe process
- SSH key should be manually added every time you open git-bash
Here is my .bashrc
that will eradicate above downsides
Put this .bashrc
into 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 be working 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 this script uses a little trick to ensure that provided environment variables are shared between git-bash instances by saving them into an .env
file.
ssh-add error connecting to agent windows 10, ssh-add creates Error connecting to agent: Connection timed out (Windows 10) ssh-add creates Error connecting to agent: Connection timed out (Windows 10)
Mihail Ignatiev
2019-05-13 12:46
above solution doesn't work for me for unknown reason. below is my workaround which was worked successfully.
1) DO NOT generate a new ssh key by using command ssh-keygen -t rsa -C"xxx@xx.com"
, you can delete existing SSH keys.
2) but use Git GUI, -> "Help" -> "Show ssh key" -> "Generate key", the key will saved to ssh automatically and no need to use ssh-add
anymore.
the agent has no identities., In summary, when ssh-add -l returns “The agent has no identities”, it means that keys used by ssh (stored in files such as ~/.ssh/id_rsa, ~/.ssh/id_dsa, etc.) are either missing, they are not known to ssh-agent, which is the authentication agent, or that their permissions are set incorrectly (for example, world writable). In summary, when ssh-add -l returns “The agent has no identities”, it means that keys used by ssh (stored in files such as ~/.ssh/id_rsa, ~/.ssh/id_dsa, etc.) are either missing, they are not known to ssh-agent, which is the authentication agent, or that their permissions are set incorrectly (for example, world writable).
Zhang Qun
2017-04-27 03:00
Try using cygwin instead of bash. that worked for me
unable to start ssh-agent service, error :1058, Having the same problem, even if I run ssh-agent manually. I've removed Windows 10 1803's OpenSSH agent (Optional Features on the Start Menu) as a workaround, but it would be nice if this worked without having to do that. Having the same problem, even if I run ssh-agent manually. I've removed Windows 10 1803's OpenSSH agent (Optional Features on the Start Menu) as a workaround, but it would be nice if this worked without having to do that.
user11767754
2019-07-11 02:15
It seems you need to run
ssh-agent
before using it:That question was answered in this topic: Could not open a connection to your authentication agent
Git Bash: Could not open a connection to your authentication agent , I got the same complain: "Could not open a connection to your authentication agent". Then I realize there are two different kind of quotation on my computer's keyboard. So I tried the one at the same position as "~": $ eval ssh-agent -s $ ssh-add ~/.ssh/id_rsa. And bang it worked. It seems you need to run ssh-agent before using it: eval `ssh-agent -s`. That question was answered in this topic: Could not open a connection
Kritana
2017-05-23 12:34