使用 Moovweb 时 Windows 上的权限被拒绝(公钥)错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17383177/
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
Permission denied (publickey) errors on Windows when using Moovweb
提问by tdesikan
I'm able to authenticate, generate, push etc just fine with my SSH keys and Moovweb credentials on my Mac and Linux machines.
我可以在 Mac 和 Linux 机器上使用我的 SSH 密钥和 Moovweb 凭据进行身份验证、生成、推送等。
However, on my Windows machine, using Git Bash, I get an SSH Permission denied (publickey)
error. The error message is below:
但是,在我的 Windows 机器上,使用 Git Bash 时,我收到了 SSHPermission denied (publickey)
错误。错误消息如下:
$> moov generate 123dsfsdsf nytimes.com
Running environment checks.
Verifying that git is installed...OK
Checking that current 123dsfsdsf directory doesn't exist...OK
Registering project with MoovCloud.
Authenticating with MoovCloud.
Checking for git access...Enter passphrase for key '/Users/firstname.lastname/.ssh/id_rsa':
Enter passphrase for key '/Users/firstname.lastname/.ssh/id_rsa':
FAILED
> Need to upload an ssh key in order to generate a project...
Found the following SSH public keys:
1 ) id_rsa.pub
2 ) new_rsa.pub
Which would you like to use with your Moovweb account? 2
Uploading public key...
Successfully uploaded public key new_rsa.pub as '[email protected]'
You are now ready to push projects to MoovCloud!
Creating project in MoovCloud...OK
Generating files...OK
Cloning project locally.
Enter passphrase for key '/Users/firstname.lastname/.ssh/id_rsa':
Enter passphrase for key '/Users/firstname.lastname/.ssh/id_rsa':
Cloning into '123dsfsdsf'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
ERROR: Error cloning git repo: exit status 128
Please try cloning the repository (git clone [email protected]:firstnameglastname/123dsfsdsf.git) again later.
Try 'moov help generate' to find out details.
Seems like a Windows-specific SSH error. Any workarounds?
似乎是 Windows 特定的 SSH 错误。任何解决方法?
回答by noj
So as mentioned in prior answers, the Permission denied
error in Windows is because you are trying to use a key other than id_rsa
.
因此,如之前的答案中所述Permission denied
,Windows 中的错误是因为您尝试使用id_rsa
.
Windows lacks the bells and whistles that Linux and Mac have to try out all your public keys when trying to connect to a server via SSH. If you're using the ssh
command, you can tell it which key to use by passing the -i
flag followed by the path to the key to use:
Windows 没有 Linux 和 Mac 在尝试通过 SSH 连接到服务器时必须尝试所有公钥的功能。如果您正在使用该ssh
命令,则可以通过传递-i
标志后跟要使用的密钥的路径来告诉它使用哪个密钥:
ssh -i ~/.ssh/moovweb_rsa [email protected]
The above command should work just fine if you've uploaded moovweb_rsa.pub
to the console (either via the moov login
command or the console UI). However, trying any git
related commands should fail because Git doesn't give you the ability to chose which key to use when connecting to the git remote. Because of this, SSH is forced to use the default key, id_rsa
, and if that key doesn't work (or doesn't exist), then the connection fails with a permission denied error.
如果您已上传moovweb_rsa.pub
到控制台(通过moov login
命令或控制台 UI),则上述命令应该可以正常工作。但是,尝试任何git
相关命令都应该失败,因为 Git 无法让您在连接到 git 远程时选择要使用的键。因此,SSH 被迫使用默认密钥 ,id_rsa
如果该密钥不起作用(或不存在),则连接将失败并出现权限被拒绝错误。
One possible solution, as suggested in other answers, is to simply rename your key to id_rsa
. For most people, this is a fine solution. However, if you already have an id_rsa
key and you would prefer to use a different key with Moovweb, you can edit your ~/.ssh/config
file by adding the following contents:
正如其他答案中所建议的那样,一种可能的解决方案是简单地将您的密钥重命名为id_rsa
. 对于大多数人来说,这是一个很好的解决方案。但是,如果您已经有一个id_rsa
密钥并且您希望在 Moovweb 中使用不同的密钥,您可以~/.ssh/config
通过添加以下内容来编辑您的文件:
Host git.moovweb.com
IdentityFile ~/.ssh/moovweb_rsa
If you append the above lines to your ~/.ssh/config
file (create it if it doesn't exist), you should be able to successfully get Git to communicate with the Moovweb remote git server. The config basically tells SSH that for the given host (git.moovweb.com
), SSH should use the given key rather than the default.
如果您将以上~/.ssh/config
几行附加到您的文件中(如果它不存在则创建它),您应该能够成功地让 Git 与 Moovweb 远程 git 服务器进行通信。配置基本上告诉 SSH,对于给定的主机 ( git.moovweb.com
),SSH 应该使用给定的密钥而不是默认值。
It's worth nothing that this happens to all Git remotes; interactions with Github, Heroku, etc... also suffer through this problem in Windows. You could easily extend your ~/.ssh/config
file to use separate SSH keys for each one of those services if you so desired:
所有 Git 遥控器都会发生这种情况,这是毫无价值的;与 Github、Heroku 等的交互……在 Windows 中也会遇到这个问题。如果您愿意,您可以轻松地扩展您的~/.ssh/config
文件,以便为这些服务中的每一项使用单独的 SSH 密钥:
Host git.moovweb.com
IdentityFile ~/.ssh/moovweb_rsa
Host github.com
IdentityFile ~/.ssh/github_rsa
Host heroku.com
IdentityFile ~/.ssh/heroku_rsa
回答by tdesikan
Quick & dirty solution: use only the default id_rsa.pub
key
快速而肮脏的解决方案:仅使用默认id_rsa.pub
密钥
Some notes:
一些注意事项:
- make sure you enter the right passphrase to
id_rsa.pub
- do notuse your other key,
new_rsa.pub
- 确保您输入正确的密码
id_rsa.pub
- 千万不能使用其他键,
new_rsa.pub
It turns out that Windows Git Bash doesn't quite come with all the cool utilities Mac/Linux users are used to. Specifically, you don't have ssh-agent
running to help handle multiple keys. Without ssh-agent
, the git
command only seems to use the default id_rsa.pub
key.
事实证明,Windows Git Bash 并没有提供 Mac/Linux 用户习惯的所有很酷的实用程序。具体来说,您不需要ssh-agent
跑步来帮助处理多个键。没有ssh-agent
,该git
命令似乎只使用默认id_rsa.pub
密钥。
You can verify this is an SSH/Windows issue following Github's awesome SSH troubleshooting guide. You'll get a Permission denied (publickey)
no matter which SSH/Git server you try to connect to.
您可以按照Github 很棒的 SSH 故障排除指南验证这是 SSH/Windows 问题。Permission denied (publickey)
无论您尝试连接到哪个 SSH/Git 服务器,您都会得到一个。