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

git push heroku master

但会出现以下错误:

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

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


当前回答

首先,确保隐藏文件在Mac中可见。如果没有:

打开终端并输入默认值,写入com.apple.FinderAppleShowAllFiles真killall查找器

下一步:

转到Users/user_name/.ssh/删除了所有文件。在ssh keygen-t dsa中打开终端类型然后heroku键:add~/.ssh/id_dsa.pub

注意:我是在Mac OSX 10.7.2 Lion中完成的。尽管其他国家的程序也应该相同。

其他回答

这是我的解决方案:

ssh-add ~/.ssh/my_heroku_key_rsa

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

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

git remote -v

然后删除错误的heroku:

git remote rm heroku

然后添加新的

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

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

这个问题困扰了我几天。

这可能会有所帮助。

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

首先,确保隐藏文件在Mac中可见。如果没有:

打开终端并输入默认值,写入com.apple.FinderAppleShowAllFiles真killall查找器

下一步:

转到Users/user_name/.ssh/删除了所有文件。在ssh keygen-t dsa中打开终端类型然后heroku键:add~/.ssh/id_dsa.pub

注意:我是在Mac OSX 10.7.2 Lion中完成的。尽管其他国家的程序也应该相同。

对于那些在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,它应该可以工作了。