Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git can't find .ssh

Tags:

git

msysgit

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 [email protected]; 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?

like image 521
rwallace Avatar asked Feb 18 '11 14:02

rwallace


People also ask

Where is my .SSH folder?

ssh directory. File paths for user's home directories can be found in /etc/passwd. The default directory and name for new keys is ~/. ssh/id_rsa, and this is where SSH will look for your keys.

Where is .SSH located Linux?

By default, the keys will be stored in the ~/. ssh directory within your user's home directory. The private key will be called id_rsa and the associated public key will be called id_rsa.


2 Answers

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.

like image 134
rwallace Avatar answered Oct 07 '22 00:10

rwallace


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

like image 21
Simon Dean Avatar answered Oct 07 '22 02:10

Simon Dean