Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH is looking in the wrong place for the public/private key pair on Windows

I'm trying to configure GIT on my Windows XP machine, but SSH keeps creating and looking for the public/private key pair in non-sensical places, e.g. /.ssh/id_rsa

Is there a configuration file in the GIT Installation for Windows where I can switch this to my home directory, or another user defined place? By default, it offers to create new key pairs at //.ssh/id_rsa but that gives me the error "Could not create directory '//.ssh'." And when I'm able to find a directory I can create it in, GIT won't look there.

like image 682
Michael Morisy Avatar asked May 15 '10 16:05

Michael Morisy


People also ask

Where does SSH look for keys on Windows?

The public part of the key is saved in the id_rsa. pub file, while the private part is saved in the id_rsa file. Both files can be accessed from this location using Explorer: C:\Users\[your user name]\. ssh .

Where do I put my private SSH key on Windows?

Enter file in which to save the key (C:\Users\username/. ssh/id_ed25519): You can press Enter to accept the default, or specify a path and/or filename where you would like your keys to be generated. At this point, you'll be prompted to use a passphrase to encrypt your private key files.

How do I open a SSH public key in Windows?

Log into the remote system using your account username and password. Note: If the remote system is not configured to support password-based authentication, you will need to ask system administrators to add your public key to the ~/. ssh/authorized_keys file in your account (if your account doesn't have ~/.

Where does SSH look for private keys?

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. pub .


2 Answers

Figured out how to manually set my home directory in Windows XP:

  1. Right click "My Computer"
  2. Choose the "Advanced" tab
  3. Click the "Environmental Variables" button
  4. Under the "System variables" section, click "New"
  5. In the "Variable name" enter in "home".
  6. In the "Variable value" enter in the path to your profile.

To do the same via command prompt do :

setx HOME "your\path\to\home" 

( Please note the suffix x - This is used to persist the change )

like image 117
Michael Morisy Avatar answered Oct 09 '22 03:10

Michael Morisy


Recommended method from MSYS2 is to set db_home in /etc/nsswitch.conf to your home directory.

Credit to @VarunAgw for pointing in the right direction.

Git-for-Windows includes env in db_home, which should read your HOME bash variable, however, it is unreliable.

like image 39
go2null Avatar answered Oct 09 '22 03:10

go2null