'How to fix SSH / Git connections after windows update broke them? Issue seems to be related to ssh-agent
I use Windows 10 / PyCharm / GitHub Desktop as my developer environment.
I use ssh keys to access my remote git repository. Everything on my computer functioned perfectly a week ago, but now it does not.
I have Github Desktop installed, and that is not affected. I can use Github Desktop to pull/push/etc from the repository. My issue is with the command line tools & with the git tool integrations into PyCharm (my IDE).
I have my RSA keys in my $HOME/.ssh/ folder and a config file in $HOME/.ssh/config that has not changed...but now everytime I attempt to do a "git fetch" command from CMD/Powershell/Git Bash I get prompted for a password. This password prompt is showing up because it is NOT reading my SSH config file and it is NOT using my RSA key!!!!
I know this is the case because I can "fix" the issue in Git Bash by executing the following commands:
eval $(ssh-agent -s)
ssh-add C:/Users/MyUsername/.ssh/id_rsa
After executing those commands, everything works perfectly in Git Bash.
I have spent HOURS googling this issue and restarrting my SSH services, rebooting my computer, resintalling my IDE, and even attempting to do a system restore back to last week....NONE of them fix the issue.
WHY do I need to add my ssh keys to Git Bash everytime I open it? It seems like it is not reading the keys/config file from the default $HOME/.ssh directory. How do I fix this? What is going on? I'm about ready to throw this computer out the window!!!
Restarting Software - Nothing Rebooting Computer - Nothing Copying $HOME/.ssh/config to multiple directories as suggested by google search results - Nothing Using Github Desktop - WORKS, but I want the CLI tools / integrated Git flow in PyCharm to work! Using Git Bash with "eval $(ssh-agent -s); ssh-add" workaround - WORKS but very cumbersome. Why doesn't it remember the keys session to session? Why do I need to execute every time?
Solution 1:[1]
Hacky solution:
I used ssh -Tvvv git@gitlab both before and after executing the "eval $(ssh-agent -s); ssh-add " workaround and loaded them into Beyondcompare and noticed that the tool was trying to grab keys from C:\SPB_Data directory in the 'before' (I have no idea what this directory is) and C:\Users\MyUsername 'after':
debug1: Next authentication method: publickey
debug1: Trying private key: /c/SPB_Data/.ssh/id_rsa
debug3: no such identity: /c/SPB_Data/.ssh/id_rsa: No such file or directory
So I simply copied all the files from C:\Users\Myusername.ssh into C:\SPB_Data.ssh and then everything worked.
The root-cause of this issues seems to be the installation of Allegro / Cadence software which OVERWRITES the $HOME environment variable and causes OpenSSH to read from that folder instead of the Windows home folder.
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 |