![](/img/trans.png)
[英]Jenkins issue with Git [Permission denied (publickey).] on Windows
[英]Permission denied (publickey) errors on Windows when using Moovweb
我能够在我的Mac和Linux机器上使用SSH密钥和Moovweb凭证进行身份验证,生成,推送等。
但是,在我的Windows机器上,使用Git Bash,我收到SSH Permission 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 'firstname.lastname@GGT.local'
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 moov@git.moovweb.com:firstnameglastname/123dsfsdsf.git) again later.
Try 'moov help generate' to find out details.
看起来像Windows特定的SSH错误。 任何解决方法?
因此,如前面的答案所述,Windows中的Permission denied
错误是因为您尝试使用id_rsa
以外的密钥。
在尝试通过SSH连接到服务器时,Windows缺乏Linux和Mac必须尝试所有公钥的花俏。 如果您正在使用ssh
命令,则可以通过传递-i
标志,然后传递要使用的密钥的路径来告诉它使用哪个密钥:
ssh -i ~/.ssh/moovweb_rsa moov@git.moovweb.com
如果您已将moovweb_rsa.pub
上传到控制台(通过moov login
命令或控制台UI),则上述命令应该可以正常工作。 但是,尝试任何与git
相关的命令都会失败,因为Git不能让您在连接到git remote时选择使用哪个键。 因此,SSH被强制使用默认密钥id_rsa
,如果该密钥不起作用(或不存在),则连接失败并显示权限被拒绝错误。
如其他答案所示,一种可能的解决方案是简单地将您的密钥重命名为id_rsa
。 对大多数人来说,这是一个很好的解决方案。 但是,如果您已经有一个id_rsa
密钥,并且您希望使用与Moovweb不同的密钥,则可以通过添加以下内容来编辑~/.ssh/config
文件:
Host git.moovweb.com
IdentityFile ~/.ssh/moovweb_rsa
如果将上面的行附加到~/.ssh/config
文件(如果它不存在则创建它),您应该能够成功地让Git与Moovweb远程git服务器通信。 配置基本上告诉SSH,对于给定的主机( git.moovweb.com
),SSH应该使用给定的密钥而不是默认密钥。
所有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
id_rsa.pub
密钥 一些说明:
id_rsa.pub
new_rsa.pub
事实证明,Windows Git Bash并不具备Mac / Linux用户习惯的所有酷工具。 具体来说,您没有运行ssh-agent
来帮助处理多个密钥。 没有ssh-agent
, git
命令似乎只使用默认的id_rsa.pub
键。
您可以在Github的SSH故障排除指南之后验证这是一个SSH / Windows问题。 无论您尝试连接哪个SSH / Git服务器,都会获得Permission denied (publickey)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.