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
id_rsa.pub
keySome notes:
id_rsa.pub
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.
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