从 Windows Cmd 行运行 git:关键文件在哪里?
所以我已经安装了 msysgit,并从 bash shell 成功运行 git。
在 bash shell 中,我使用 ssh-keygen
创建了密钥 - 一切正常。
关键文件位于我的 %userprofile%\.ssh
文件夹中(在 bash shell 中,它是:~/.ssh
)。
我能够连接到我的服务器(在我的情况下不要混淆)。
接下来,我确实希望能够从 Windows Cmd shell 运行 git。
将 c:\msysgit\bin
和 c:\msysgit\mingw\bin
添加到搜索路径。
Git 在本地运行得很好:分支、合并、添加、提交、签出……运行良好。
但是,尝试使用服务器失败,并显示:“权限被拒绝(公钥)。
”
它看起来像 git,当从命令行执行时会查看尝试分配密钥文件的不同位置,或者导致其失败的其他原因。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要让 mysysgit 命令行找到 .ssh 密钥,您需要将
%HOME%
指向包含 .ssh 文件夹的目录通常您可以这样做
To get the mysysgit command line to find the .ssh keys you'll need to have
%HOME%
point to the directory containing the .ssh folderOften you can just do
在 Windows DOS 文件中,您需要定义一个
%HOME%
环境变量。默认情况下,DOS 会话中不存在
HOME
。您可以将其设置为
%userprofile%
,因为这已经是您当前的设置。您还可以将其添加到您的用户环境变量中,以便任何 DOS 会话都能获取它。
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.