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

git push heroku master

但会出现以下错误:

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

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


当前回答

要遵循的顺序

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

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

其他回答

这个问题困扰了我几天。

这可能会有所帮助。

1) 看看你现在在Heroku有什么钥匙。

$ heroku keys
=== 1 key for joe@example.com
ssh-dss AAAAB8NzaC...DVj3R4Ww== joe@workstation.local

2) 构建~/.ssh/config文件:

$ sudo vim ~/.ssh/config

使用此信息编辑

Host heroku.com
Hostname heroku.com 
Port 22 
IdentitiesOnly yes 
IdentityFile ~/.ssh/ssh-dss # location and name of your private key
TCPKeepAlive yes 
User joe@workstation.local

在尝试了所有这些想法之后,我仍然有问题。这是我的问题:

我的远程heroku存储库被吓坏了。我将其刷新如下:

git remote -v

然后删除错误的heroku:

git remote rm heroku

然后添加新的

git remote add heroku git@heroku.com:sitename.git

您可以从应用程序的Heroku设置页面获取站点名称。祝你好运

如果您是windows用户,这里的其他解决方案可能无法解决您的问题。

我使用的是Windows 7 64位+Git-1.7.7.1-review20111027,解决方案是将我的密钥从C:\users\user\.ssh复制到C:\Program Files(x86)\Git\.ssh。这是Git客户端在推送到heroku时查找密钥的地方。

我希望这有帮助。

要遵循的顺序

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

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

分享我的经验:

Git(我自己安装的)正在查找名为“id_rsa”的密钥。

所以我尝试将我的密钥重命名为“id_rsa”和“id_rsa.pub”,结果成功了。

顺便说一句,我肯定还有其他方法可以做到这一点,但我还没有深入研究。