'Ssh keeps forgetting the keys

This is the problem: I use Git Shell installed with GitHub for Windows. I have 3 ssh keys inside C:\Users\MyName\.ssh:

  • github_rsa (this is the key generated by github for windows)
  • id_rsa (generated by me)
  • tm_rsa (generated by me)

I inserted the key with this command:

ssh-add ~/.ssh/github_rsa
ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/tm_rsa

Everytime I reboot the computer, ssh keeps forgetting the keys. if i do this command ssh-add -L, it shows only one key, usually github_rsa.

How can I avoid having to enter the keys each time?



Solution 1:[1]

Try

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

If you see this message, just run ssh-add.

Here's the source: https://stackoverflow.com/a/39616339/2941404

Solution 2:[2]

First add your private key via ssh-add:

ssh-add /path-to-private-key 

then enter the passphrase.

and then run: ssh-add

if You've already lost connection, I mean ssh-add has no identities, and then you run ssh-add, it will not work. To make it work you have to do all the process in one session.

To automate that just add this line to your .bashrc file:

ssh-add -L || ssh-add /path-to-private-key;ssh-add;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rajjeet
Solution 2