Running git from Windows Cmd line: Where are key files?

给你一囗甜甜゛ 提交于 2019-12-18 10:19:50

问题


So I've installed msysgit, and run git successfuly from the bash shell.

From within the bash shell, I've created keys with ssh-keygen - everything works fine.
Key files are in my %userprofile%\.ssh folder (from the bash shell, it is: ~/.ssh).
I'm able to connect to my server (unfuddle in my case).

Next, I do want to be able to run git from the Windows Cmd shell.
Adding c:\msysgit\bin and c:\msysgit\mingw\bin to the search path.
Git is working locally just fine: branch, merge, add, commit, checkout, ... working well.

However, trying to work with the server fails, with: 'Permission denied (publickey).'
It looks like git, when executed from command line looks at a different location trying to allocated the key files, or another reason causing it to fail.


回答1:


To get the mysysgit command line to find the .ssh keys you'll need to have %HOME% point to the directory containing the .ssh folder

Often you can just do

set HOME=%USERPROFILE%



回答2:


From a Windows DOS file, you need to define a %HOME% environment variable.

HOME doesn't exist in a DOS session by default.
You can set it to %userprofile%, since this is already your current setting.
You also can add it to your user environment variables, in order for any DOS session to get it.



来源:https://stackoverflow.com/questions/6127063/running-git-from-windows-cmd-line-where-are-key-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!