Permission denied (publickey) errors on Windows when using Moovweb

后端 未结 2 875
北荒
北荒 2021-02-14 00:09

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

2条回答
  •  面向向阳花
    2021-02-14 00:41

    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
    

提交回复
热议问题