我正在尝试使用以下命令行将代码部署到heroku:
git push heroku master
但会出现以下错误:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
我已经上传了我的公共SSH密钥,但仍然会出现此错误。
我正在尝试使用以下命令行将代码部署到heroku:
git push heroku master
但会出现以下错误:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
我已经上传了我的公共SSH密钥,但仍然会出现此错误。
当前回答
这个问题困扰了我几天。
这可能会有所帮助。
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
其他回答
这是我的解决方案:
ssh-add ~/.ssh/my_heroku_key_rsa
我只想补充一点,该目录不一定是C:\Users\[用户名]\.ssh。它是您在其中创建公钥的目录。
例如,我在Windows中的主目录已更改为C:\[用户名]。ssh子文件夹中的主目录是创建密钥的最佳位置,也是最可能的位置。您可以使用以下命令检查Windows中的主目录:
echo %HOMEPATH%
如果您是windows用户,这里的其他解决方案可能无法解决您的问题。
我使用的是Windows 7 64位+Git-1.7.7.1-review20111027,解决方案是将我的密钥从C:\users\user\.ssh复制到C:\Program Files(x86)\Git\.ssh。这是Git客户端在推送到heroku时查找密钥的地方。
我希望这有帮助。
如果其他答案对你不起作用。试试这个!
有时候,你只需要再推一次。由于网络连接缓慢(当您下载或使用p2p时),我今天遇到了这种情况。
请参见下面的截图:
当TortoiseGIT安装在我的机器上时,我遇到了这个问题。将环境变量GIT_SSH从
"c:\Program Files\TortoiseGit\bin\TortoisePlink.exe"
to
"c:\Program Files (x86)\Git\bin\ssh.exe"
使用ssh-keygen和keys完成本教程:add,它起作用了!