2013-01-15 198 views
50

我在关注ruby.railstutorial。我运行命令“git push heroku master”并且吐出这个错误。git push heroku主人权限被拒绝

Permission denied (publickey). 
fatal: Could not read from remote repository. 
Please make sure you have the correct access rights 
and the repository exists. 

我为我的Rails应用程序 “/用户/ lexi87/rails_projects/first_app” 里。任何解决方案

+6

你可能想看看Heroku的指导来管理你的SSH密钥:https://devcenter.heroku.com/articles/keys – derekerdmann

回答

65

避免此类错误的最佳方法是使用一对公钥/私钥对,而不是用于heroku的额外密钥。这样你(或你的系统)就不能选择一个错误的密钥来登录heroku。

如果您遇到此错误,您做了错误的事情。检查这个网站:https://devcenter.heroku.com/articles/keys

如果你有这个错误,最好的办法是删除不必要的密钥,只使用一个。

如果您的系统需要多个密钥对,您可以为heroku设置一个密钥。这是通过以下命令完成的:

heroku keys:add 
+21

谢谢。我不得不运行命令heroku keys:add,然后选择id_rsa选项。 –

+0

对于Windows用户来说,寻找低于@ mjulmer的回答方式.... – bcm

8

我面临同样的问题。在我的.ssh文件夹中,我有一个名为“已知主机”的文件。我一直试图删除并创建新的ssh密钥,它不起作用。最后我刚刚删除一切的.ssh包括“已知主机”,然后创建使用新的RSA密钥:使用我加入这个新的关键的Heroku

ssh-keygen -t rsa 

则:

heroku keys:add 

然后创建新的Heroku的回购,把我的应用吧:

heroku create 
git push heroku master 
0

我创建了一个键与

ssh-keygen -t rsa 

并使用了不同于id_rsa的文件名(在我的情况下为heroku)。我加入了关键的Heroku与

heroku keys:add 

在试图把我的主分支的Heroku我总是收到以下错误:

$ git push heroku master
The authenticity of host 'heroku.com
(50.19.85.132)' can't be established. RSA key fingerprint is
8b:48:5e:67:0e:c9:16:47:32:99:87:0c:1f:c8:60:bb. Are you sure you want
to continue connecting (yes/no)? yes Warning: Permanently added
'heroku.com,50.19.85.132' (RSA) to the list of known hosts. Permission
denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

当我发现的git只用我id_rsa钥匙从另一个SSH-访问(你可以通过你的git gui来检查:帮助 - > SSH密钥)。

我改名为我的.ssh目录C:\用户\%USERNAME%的.ssh.ssh.bak和复制我的Heroku的私钥和公钥(从.ssh.bak目录)到新创建的.ssh目录并将其命名为id_rsa(和id_rsa.pub)。

现在正在推动和预期一样:

git push heroku master 
13

一些帮助Windows 7用户使用Github的Windows客户端安装:

即使Heroku的工具区报告它发现我git_hub公钥并上载,“混帐推heroku主'失败。采取以下步骤后,它工作正常。

  1. 您的用户文件夹下创建的.ssh文件夹,如果一个不存在。如果它是 ,那么删除它中的所有文件(这里假设你可以用ssh键从头开始)。

  2. 在Windows资源管理器中,右键单击 的.ssh文件夹,然后从上下文菜单中的Git的bash。这与Github Windows客户端软件一起安装。

  3. 在bash的窗口项目的输入 “当提示输入 密码(不失去这个)。

  4. 关闭的bash shell窗口。

  5. 从命令提示符根,进入heroku keys:add。 这将找到并上传你只是从你的/.ssh文件创建 的Heroku。

关键

现在你可以输入git push heroku master来推送你的应用程序到Heroku。 注意:完成后,您需要将新生成的ssh公钥添加到您的Github帐户中。

+0

完美@mjulmer。试了很多选择,但最后你的解决方案为我工作。非常感谢。这是Windows 7用户,当然:) –

+0

此外我认为你的方法是什么,我想,主要的区别是“-C EMAILADDRESS”属性。我的情况是把Windows用户名作为windows @ windows-PC而不是我的电子邮件地址注册到你的heroku。再次不确定是否真的是这个原因:) –

+0

谢谢!我兜兜与其他的答案对非Windows – bcm

4
ssh-keygen -t rsa 

上面是可选的,因为您也可以链接到现有的密钥。 Heroku会在下一步中提示选择密钥。

heroku keys:add 

添加您新创建的密钥或现有的密钥。如果你还在运行到这个问题,你很可能需要通过执行以下向键添加到SSH密钥的机器的列表:

ssh-add ~/.ssh/name_of_your_rsa 

,并确认您的SSH已添加

ssh-add -l 

这应该让你访问推到Heroku的远程回购。

2

在OSX上,我有遇到同样的问题,我是越来越

no such identity: /Users/me/.ssh/yourPrivateKey: No such file or directory 
Permission denied (publickey). 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

我试图创建使用ssh-凯基-t RSA然后用Heroku的键添加一个新的关键:添加,但它没有帮助。

然后我发现一个名为配置在〜/ .ssh /,和里面的文件有:

ServerAliveInterval 300 
ServerAliveCountMax 3 

host heroku.com 
    user git 
    hostname heroku.com 
    identityfile ~/.ssh/yourPrivateKey 

所以我通过改变yourPrivateKey我的私人密钥文件名(id_rsa默认)aaand它的工作:)

0

如果您正在使用Windows,请务必使用git-bash而不是Powershell /命令提示符。

如果你只是想重置SSH密钥:

  1. 删除用户的.ssh目录
  2. 开放混帐的bash
  3. SSH-凯基-t RSA
  4. Heroku的键:添加

,然后你就可以混帐推。