Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied (publickey) errors on Windows when using Moovweb

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?

like image 283
tdesikan Avatar asked Jun 29 '13 18:06

tdesikan


People also ask

How do I fix SSH permission denied publickey?

This error comes up when using a wrong private key or no key at all when trying to connect via SSH. To resolve the problem, you should generate a new key pair and connect using that new set of keys.

How do I fix permission denied publickey password or permission denied please try again?

Solution 1: Enable Password Authentication If you want to use a password to access the SSH server, a solution for fixing the Permission denied error is to enable password login in the sshd_config file. In the file, find the PasswordAuthentication line and make sure it ends with yes .


2 Answers

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
like image 82
noj Avatar answered Nov 06 '22 04:11

noj


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.

like image 20
tdesikan Avatar answered Nov 06 '22 02:11

tdesikan