本文介绍了使用Moovweb时,Windows上的权限被拒绝(publickey)错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



然而,在我的Windows上,我可以使用我的SSH密钥和Moovweb凭证来验证,生成,推送等。机器,使用Git Bash,我得到一个SSH Permission denied(publickey)错误。错误消息如下:

  $> moov生成123dsfsdsf nytimes.com 
运行环境检查。
验证是否安装了git ... OK
检查当前的123dsfsdsf目录不存在... OK
使用MoovCloud注册项目。
使用MoovCloud进行身份验证。
检查git访问...为密钥'/Users/firstname.lastname/.ssh/id_rsa'输入密码短语:
为密钥'/Users/firstname.lastname/.ssh/id_rsa'输入密码短语' :
失败
>需要上传一个ssh密钥才能生成一个项目...
找到以下SSH公钥:
1)id_rsa.pub
2)new_rsa.pub
哪个会你喜欢用你的Moovweb账户? 2
上传公钥...
成功上传公钥new_rsa.pub作为'[email protected]'
您现在已准备好将项目推送到MoovCloud!
在MoovCloud中创建项目... OK
生成文件... OK
在本地克隆项目。
为密钥'/Users/firstname.lastname/.ssh/id_rsa'输入密码短语:
输入密钥'/Users/firstname.lastname/.ssh/id_rsa'的密码短语:
克隆到'123dsfsdsf'...
权限被拒绝(publickey)。
致命:无法从远程存储库读取。
请确保您具有正确的访问权限
并存在存储库。
错误:克隆git repo时出错:退出状态128
请稍后再尝试克隆存储库(git clone [email protected]:firstnameglastname / 123dsfsdsf.git)。
尝试'moov help generate'来找出详细信息。

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

解决方案

正如前面的答案中所提到的, Permission denied Windows中的错误是因为您试图使用 id_rsa 以外的其他键。



Windows缺少铃声和口哨声称Linux和Mac在尝试通过SSH连接到服务器时必须尝试所有公用密钥。如果你使用 ssh 命令,你可以通过传递 -i 标志来告诉它使用哪个键通过密钥的使用路径:

  ssh -i〜/ .ssh / moovweb_rsa [email protected] 

如果您上传了 moovweb_rsa.pub 到控制台(通过 moov login 命令或控制台UI)。然而,尝试任何 git 相关命令都会失败,因为Git不能让您选择连接到git远程时使用哪个密钥。因此,SSH被迫使用默认密钥 id_rsa ,如果该密钥不起作用(或不存在),则连接将失败许可被拒绝错误。



其他答案中提出的一种可能的解决方案是简单地将您的密钥重命名为 id_rsa 。对大多数人来说,这是一个很好的解决方案。但是,如果您已经有 id_rsa 键,并且您希望使用Moovweb的其他键,则可以编辑〜/ .ssh / config

 主机git.moovweb.com 
IdentityFile〜 /.ssh/moovweb_rsa

如果将以上行添加到〜/ .ssh / config 文件(如果它不存在,创建它),你应该能够成功地让Git与Moovweb远程git服务器进行通信。该配置基本上告诉SSH,对于给定的主机( git.moovweb.com ),SSH应该使用给定的键而不是默认值。



这一切都不值得Git的遥控器;与Github,Heroku等的交互......在Windows中也会遇到这个问题。如果您愿意的话,您可以轻松地扩展您的〜/ .ssh / config 文件以对这些服务中的每一个使用单独的SSH密钥:

 主机git.moovweb.com 
IdentityFile〜/ .ssh / moovweb_rsa

主机github.com
IdentityFile〜 /.ssh/github_rsa

主机heroku.com
IdentityFile〜/ .ssh / heroku_rsa


I'm able to authenticate, generate, push etc just fine with my SSH keys and Moovweb credentials on my Mac and Linux machines.

However, on my Windows machine, using Git Bash, I get an SSH Permission denied (publickey) error. The error message is below:

$> 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?

解决方案

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.

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:

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.

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:

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.

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:

Host git.moovweb.com
    IdentityFile ~/.ssh/moovweb_rsa

Host github.com
    IdentityFile ~/.ssh/github_rsa

Host heroku.com
    IdentityFile ~/.ssh/heroku_rsa

这篇关于使用Moovweb时,Windows上的权限被拒绝(publickey)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 03:49