使用Moovweb时Windows上的权限被拒绝(publickey)错误

tde*_*kan 12 windows git ssh git-bash 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.
Run Code Online (Sandbox Code Playgroud)

看起来像Windows特定的SSH错误.任何解决方法?

小智 15

因此,如前面的答案中所述Permission denied,Windows中的错误是因为您尝试使用除以外的密钥id_rsa.

在尝试通过SSH连接到服务器时,Windows缺乏Linux和Mac必须尝试所有公钥的花俏.如果您正在使用该ssh命令,则可以通过传递-i标志,然后传递要使用的密钥的路径来告诉它使用哪个密钥:

ssh -i ~/.ssh/moovweb_rsa moov@git.moovweb.com
Run Code Online (Sandbox Code Playgroud)

如果您已上传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
Run Code Online (Sandbox Code Playgroud)

如果将上面的行追加到您的~/.ssh/config文件中(如果它不存在则创建它),您应该能够成功地让Git与Moovweb远程git服务器通信.配置基本上告诉SSH,对于给定的host(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
Run Code Online (Sandbox Code Playgroud)