Permission denied (publickey) errors on Windows when using Moovweb

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

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 '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. 

Seems like a Windows-specific SSH error. Any workarounds?

回答1:

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 moov@git.moovweb.com 

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 


回答2:

Quick & dirty solution: use only the default id_rsa.pub key

Some notes:

  1. make sure you enter the right passphrase to id_rsa.pub
  2. do not use your other key, 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.

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!