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

git push heroku master

但会出现以下错误:

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

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


当前回答

这是我的解决方案:

ssh-add ~/.ssh/my_heroku_key_rsa

其他回答

推送时使用

git push heroku production:master 

使用主目录~/.ssh/id_rsa下的公钥

要解决此问题

您应该以其他用户身份登录,可能是root用户

sudo su 

然后通过发出以下命令重新开始

heroku keys:clear //removes existing keys
ssh-keygen -t rsa //generates a new key in ~/.ssh folder (set a password)
heroku keys:add   //uploads the new key, ~/.ssh/id_rsa is uploaded                      
git push heroku production:master

我重新安装了heroku工具带,它工作了。

我也遇到了同样的问题;以下步骤将有助于:

首先,登录:heroku登录清除所有键:heroku键:清除删除.ssh/文件夹中本地文件夹中的所有文件(所有.pub文件和know_host)再次登录:heroku login-u将无需按键提示,因此请按照屏幕上的说明进行操作。

如果其他答案对你不起作用。试试这个!

有时候,你只需要再推一次。由于网络连接缓慢(当您下载或使用p2p时),我今天遇到了这种情况。

请参见下面的截图:

对于那些在Windows7上尝试了上述所有方法但仍然没有成功的人,我做了以下工作:-从Git目录C:\Program Files(x86)\Git\中打开GitBash.exe(不要打开命令提示符,这不起作用)。-如上所述添加以下内容,但必须删除#

Host heroku.com
Hostname heroku.com 
Port 22 
IdentitiesOnly yes 
IdentityFile ~/.ssh/ssh-dss
TCPKeepAlive yes 
User joe@workstation.local

现在运行gitpushherokumaster,它应该可以工作了。