我正在尝试使用以下命令行将代码部署到heroku:

git push heroku master

但会出现以下错误:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

我已经上传了我的公共SSH密钥,但仍然会出现此错误。


当前回答

dmajkic的解决方案最终帮助了我:

对于Windows用户,这可能意味着:git客户端找不到您的密钥。检查c:\Users\UserName.ssh\和!环境变量HOME=c:\Users\UserName\

其他回答

下面是说明如何管理ssh密钥的链接:https://devcenter.heroku.com/articles/keys#adding-heroku的关键

要遵循的顺序

$ heroku login
$ ssh-keygen -t rsa
$ heroku keys:add

当执行第二条语句时,它会要求输入,只需按Enter(回车)三次,就会添加一个键。

尝试修复磁盘实用程序(Mac OS X)中的权限。帮助了我

如果您已上载密钥,请尝试删除密钥,然后重新上载它有一把新钥匙。

 heroku keys:remove //removes the existing key
 ssh-keygen -t rsa //generates a new key in ~/.ssh folder
 heroku keys:add    //uploads the new key, if no arguments r passed then the key generated                              
                    //in default directroy i.e., ~/.ssh/id_rsa is uploaded
 git push heroku

这应该奏效。

这是我的解决方案:

ssh-add ~/.ssh/my_heroku_key_rsa