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

git push heroku master

但会出现以下错误:

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

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


当前回答

检查heroku的.ssh配置。转到.ssh文件夹并打开配置文件

cd ~/.ssh
subl config

“subl”用于Sublime文本,但您可以使用任何您想要的编辑器。查找“IdentityFile”行,并确保它列出了非公钥:

IdentityFile "/Users/ircmullaney/.ssh/my_ssh"

not

IdentityFile "/Users/ircmullaney/.ssh/my_ssh.pub"

这对我来说很有用。我不知道为什么我的配置文件中有公共版本,但它确实有,并且抛出了错误:

Permissions 0644 for '/Users/ircmullaney/.ssh/my_ssh.pub' are too open.

其他回答

当TortoiseGIT安装在我的机器上时,我遇到了这个问题。将环境变量GIT_SSH从

"c:\Program Files\TortoiseGit\bin\TortoisePlink.exe"

to

"c:\Program Files (x86)\Git\bin\ssh.exe"

使用ssh-keygen和keys完成本教程:add,它起作用了!

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

首先,确保隐藏文件在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/authorized_keys文件设置不正确。验证:

它在正确的路径上。文件的权限为0600。~/.ssh的权限为0700。

这是我的解决方案:

ssh-add ~/.ssh/my_heroku_key_rsa