what is the default path for Git .ssh?

2019-06-04 05:31发布

问题:

I am running Git 1.9.4 on my Windows 8. My OS is installed on a SSD. My Git installation is located on another hard drive. I'm pretty new to git. How does Git choose where to put the .ssh folder for private and public keys? My home directory is on C: but Git is installed on D:. Does Git recognize (for example when pushing) that there is a .ssh folder, although its located in another path then it would usually be?

回答1:

How does Git choose where to put the .ssh folder

If you run git through git-cmd.bat, it will look for ssh keys in %HOME%/.ssh.

HOME is defined in git-cmd.bat (by default: %USERPROFILE%)

As long as HOME is set (to any folder you want), Git will use it (even if it is installed on another drive).

You will use ssh-keygen to generate your public/private keys.


The same applies for git bash: the keys will be in ~/.ssh.



回答2:

This answer definitely led me on the right track.

Using the command ssh-keygen -t rsa -C "your_email@example.com" is correct.

Git will create this .ssh folder under %HOME%/.ssh as stated, but only if you do not define a file yourself, such as key.txt for example. This guide really helped me: Generating SSH keys



标签: git github ssh key