1

I recently reinstalled Windows on my PC. However the new SSH location on my PC is different because the username is different. When I try to sync git, it still looks for the previous ssh location.

My question is simply why is it looking for the previous location?

EDIT

I forgot to mention that I copied all my repositories and .ssh folder over.

gagarwa
  • 1,426
  • 1
  • 15
  • 28

2 Answers2

1

Git will always look by default for ssh keys in %USERPROFILE%\.ssh\id_rsa(.pub).

Warning, with Git 2.19+, you need to add the -m PEM option to ssh-keygen:

ssh-keygen -t rsa -m PEM -P ""

The only way Git would look elsewhere is if you have restored your %USERPROFILE%\.ssh\config file, in which you could have set a specific path for a private key.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • You are right. I copied and stored my entire .ssh folder since I had multiple keys I was using. In the config file, I had to update the location it was looking for my keys. – gagarwa Feb 01 '19 at 21:38
  • @gagarwa OK, that makes sense: the config can specify through the IdentityFile entry a different path. Note that environment variable can also influence said path, since Git 2.10+: https://stackoverflow.com/a/38474220/6309 – VonC Feb 01 '19 at 21:40
0

all it's looking for is the private key. since you reinstalled Windows, you would have lost you previous key. only option you have is to generate a new key and configure it's corresponding public key on git again.

P.S: you are incorrect in assuming that it's due to change in location or that git's even looking for your key at a certain location.

AppleCiderGuy
  • 1,249
  • 1
  • 9
  • 16