You can just restart agent by eval ssh-agent -s and add older key using ssh-add ~/. ssh/id_rsa. If you generate new SSH key then you will need to update that key in all your services such as github, bitbucket, etc.
On the other hand, if you get the “Could not open a connection to your authentication agent” error again, the agent needs full reassignment. If you're working with the regular shell, then just run ssh-agent /bin/sh and then ssh-add ~/. ssh/id_rsa, once again making sure to replace the name of the key.
ssh-agent
?You might need to start ssh-agent
before you run the ssh-add
command:
eval `ssh-agent -s`
ssh-add
Note that this will start the agent for msysgit Bash on Windows. If you're using a different shell or operating system, you might need to use a variant of the command, such as those listed in the other answers.
See the following answers:
To automatically start ssh-agent and allow a single instance to work in multiple console windows, see Start ssh-agent on login.
eval
instead of just ssh-agent
?To find out why, see Robin Green's answer.
Also, whenever I use ssh-add
, I always add private keys to it. The file ~/.ssh/id_rsa.pub
looks like a public key, I'm not sure if that will work. Do you have a ~/.ssh/id_rsa
file? If you open it in a text editor, does it say it's a private key?
I tried the other solutions to no avail. I made more research and found that the following command worked. I am using Windows 7 and Git Bash.
eval $(ssh-agent)
More information in: https://coderwall.com/p/rdi_wq
The following command worked for me. I am using CentOS.
exec ssh-agent bash
To resolve this error:
bash:
$ eval `ssh-agent -s`
tcsh:
$ eval `ssh-agent -c`
Then use ssh-add
as you normally would.
Hot Tip:
I was always forgetting what to type for the above ssh-agent commands, so I created an alias in my .bashrc
file like this:
alias ssh-agent-cyg='eval `ssh-agent -s`'
Now instead of using ssh-agent
, I can use ssh-agent-cyg
E.g.
$ ssh-agent-cyg
SSH_AUTH_SOCK=/tmp/ssh-n16KsxjuTMiM/agent.32394; export SSH_AUTH_SOCK;
SSH_AGENT_PID=32395; export SSH_AGENT_PID;
echo Agent pid 32395;
$ ssh-add ~/.ssh/my_pk
Original Source of fix:
http://cygwin.com/ml/cygwin/2011-10/msg00313.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With