Git 找不到 .ssh
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5042482/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git can't find .ssh
提问by rwallace
Problem using msysgit on Windows; it can't find .ssh/id_rsa, even though it is present where it should be.
在 Windows 上使用 msysgit 的问题;它找不到 .ssh/id_rsa,即使它出现在它应该出现的地方。
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.
我确认这是 ssh -v [email protected] 的问题;该命令仅在我使用 -i 选项将其明确指向正确的 id_rsa 文件时才起作用,但据我所知,git 本身没有这样的选项;我在 Google 或提供的文档中找不到任何内容。
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.
奇怪的是,几个月前我上次使用 git 时它运行良好,从那以后我没有改变任何东西,这似乎是一个可能的原因。
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)
生成新的 id_rsa
将 .ssh 放入当前目录
将 .ssh 放入根目录
卸载 msysgit 并重新安装最新版本
设置HOME环境变量
安装 TortoiseGit 并尝试使用它(根本不起作用)
Any ideas what else to try?
还有什么想法可以尝试吗?
采纳答案by rwallace
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.
问题是有两个不同的 git 命令,git.exe(实际程序)和 git.cmd(设置必要的东西,使其在 Windows 上工作)。根据您在安装时设置的选项,您最终可能会遇到这样一种情况,即前者而不是后者最终会出现在您的路径中,因此它不起作用。然后,除非您已运行 git.cmd,否则有关 ssh.exe 的常规调试建议将不起作用。
In a nutshell, just make sure you're running git.cmd instead of git.exe.
简而言之,只需确保您运行的是 git.cmd 而不是 git.exe。
回答by Simon Dean
Oddly msysgit has it's own .ssh directory:
奇怪的是 msysgit 有它自己的 .ssh 目录:
C:\Program Files (x86)\Git\.ssh
C:\Program Files (x86)\Git\.ssh
Placing your ssh key there should work. It solved the problem for me
将您的 ssh 密钥放在那里应该可以工作。它为我解决了问题
回答by sparrowt
I had this problem with git in Msys/MinGW where it couldn't find my private key, despite being able to ssh into the server fine.
我在 Msys/MinGW 中的 git 遇到了这个问题,尽管能够很好地通过 ssh 进入服务器,但它找不到我的私钥。
The problem was that the entry in ~/.ssh/config
said:
问题是条目中~/.ssh/config
说:
Host github.com
IdentityFile /home/username/.ssh/id_rsa
However Git required the full path from a Windows point of view like this instead:
然而,从 Windows 的角度来看,Git 需要完整路径,而不是这样:
Host github.com
IdentityFile c:/mingw/msys/1.0/home/username/.ssh/id_rsa
and then it worked.
然后它起作用了。
To discover this path from msys, run cd ~/.ssh
and then pwd -W
要从 msys 中发现此路径,请运行cd ~/.ssh
然后pwd -W
回答by abergmeier
Our admins changed the HOMEDRIVE
on Windows and afterwards tools like ssh did no longer find their config anymore. Seems like HOMEDRIVE
is used as default value for HOME
.
我们的管理员HOMEDRIVE
在 Windows 上更改了ssh 之后,ssh 之类的工具不再找到他们的配置。似乎HOMEDRIVE
用作HOME
.
回答by mpapis
The windows way is to import your ssh key to puttyand use putty agent.
windows 方法是将您的 ssh 密钥导入 putty并使用 putty 代理。