Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh-agent suddenly "lost" my key

Tags:

git

ssh

I'm using Git on Windows, and a week ago I set up my SSH keys. I cloned my repos and it worked fine.

Then, today I tried to make a pull and this happens:

$ git pull
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I tried to run a ssh-add-l and returned this:

$ ssh-add -l
The agent has no identities.

However my key files are on the same place. I faced this problem a while ago on a Mac, but then I just did another key and it worked. What can I do without generating another SSH key?

like image 711
athosbr99 Avatar asked Sep 06 '15 00:09

athosbr99


People also ask

Why did my SSH keys disappear?

As a security precaution, GitHub automatically deletes SSH keys that haven't been used in a year.

Can SSH keys be stolen?

SSH key management has a variety of pitfalls such as stale credentials, orphaned keys, and can easily conceal malicious keys inserted by malware or intruders to maintain persistence. At Sandfly we have seen incidents where SSH credentials were stolen or used to insert backdoor access for intruders and malware.

Where are ssh-agent keys stored?

By default, the agent uses SSH keys stored in the . ssh directory under the user's home directory. The ssh-add command is used for adding identities to the agent.

How do I find my SSH key ssh-agent?

Enter ls -al ~/.ssh to see if existing SSH keys are present. Check the directory listing to see if you already have a public SSH key.


1 Answers

ssh-agent is not persistent across reboots. You need to start agent (equivalent to Linux eval $(ssh-agent)) and then you need to add them manually after reboot or setup some script to load them automatically.

If you have have your keys in "default location", like ~/.ssh/id_rsa, it should be enough to run ssh-add, otherwise you need to run ssh-add path/to/your/private/key.

like image 105
Jakuje Avatar answered Sep 27 '22 21:09

Jakuje