13

Problem using msysgit on Windows; it can't find .ssh/id_rsa, even though it is present where it should be.

I verified that's the problem with ssh -v git@github.com; that command works when and only when I use the -i option to explicitly point it at the correct id_rsa file but as far as I can tell, git itself doesn't have such an option; and I can't find anything either on Google or in the supplied documentation.

The peculiar thing is, it worked fine last time I used git a few months ago, and I haven't changed anything since then that seems a likely cause.

I've tried the following, all to no effect:

  • Generating new id_rsa

  • Putting .ssh in current directory

  • Putting .ssh in root directory

  • Uninstalling msysgit and reinstalling the latest version

  • Setting the HOME environment variable

  • Installing TortoiseGit and trying that instead (didn't work at all)

Any ideas what else to try?

9
  • 3
    On linux, at least, ssh will accept -vv and -vvv to pump up the verbosity - maybe that will tell you where exactly it's looking for the key?
    – Cascabel
    Feb 18, 2011 at 15:22
  • It does indeed accept those, but the output is the same: it claims to be looking in /.ssh/id_rsa, but it lies (since I did put a copy of .ssh in the root directory, which ssh can read if explicitly pointed to).
    – rwallace
    Feb 18, 2011 at 15:27
  • Huh. Why is it looking in /.ssh/id_rsa instead of $HOME/.ssh/id_rsa, anyway?
    – Cascabel
    Feb 18, 2011 at 15:45
  • If I knew that, I'd know more than I do now!
    – rwallace
    Feb 18, 2011 at 15:50
  • When you say you set HOME, you mean within the shell, right? And you exported it? (I'm sure you did, I'm just short on ideas like you are - I'm pretty sure ssh just looks in $HOME/.ssh/id_rsa so this really makes it look like $HOME is actually empty`...)
    – Cascabel
    Feb 18, 2011 at 16:26

5 Answers 5

8

Found it!

The problem is that there are two different git commands, git.exe (the actual program) and git.cmd (which sets up the necessary stuff for it to work on Windows). Depending on what options you set at install time, you can end up with a scenario where the former rather than the latter is the one that ends up in your path, so it doesn't work. Then the usual debugging suggestions regarding ssh.exe don't work unless you've run git.cmd.

In a nutshell, just make sure you're running git.cmd instead of git.exe.

1
  • 1
    And how does one make sure of this?
    – Dumle29
    May 20, 2018 at 18:14
3

I had this problem with git in Msys/MinGW where it couldn't find my private key, despite being able to ssh into the server fine.

The problem was that the entry in ~/.ssh/config said:

Host github.com
IdentityFile /home/username/.ssh/id_rsa

However Git required the full path from a Windows point of view like this instead:

Host github.com
IdentityFile c:/mingw/msys/1.0/home/username/.ssh/id_rsa

and then it worked.

To discover this path from msys, run cd ~/.ssh and then pwd -W

1

Oddly msysgit has it's own .ssh directory:

C:\Program Files (x86)\Git\.ssh

Placing your ssh key there should work. It solved the problem for me

1
  • 2
    Is this still the case? Could not find this folder. Nov 12, 2014 at 10:43
0

The windows way is to import your ssh key to putty and use putty agent.

1
  • The linked page says using putty is an option you select at install time, but the latest version of msysgit doesn't give me any such option; has this changed or something?
    – rwallace
    Feb 19, 2011 at 1:22
0

Our admins changed the HOMEDRIVE on Windows and afterwards tools like ssh did no longer find their config anymore. Seems like HOMEDRIVE is used as default value for HOME.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.