由于关键指纹无法推送到Heroku

mre*_*mre 131 git ssh heroku git-push

我是Rails的新手,我试图将一个非常简单的应用程序部署到Heroku.这是我部署的第二个应用程序,第一个我能够做到这一点就好了.但是我遇到了一些问题.每当我" git push heroku master "时,我都会收到此错误:

!你的密钥有指纹xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx无权访问my_heroku_app.

致命:远程端意外挂断

我在登录heroku后尝试管理我的密钥.如果我输入我的控制台" heroku keys ",那么我得到:

myemailaddress没有钥匙.

但是,如果我运行命令" heroku keys:add ",我会得到

找到现有公钥:/Users/michele/.ssh/id_rsa.pub上传ssh公钥/Users/michele/.ssh/id_rsa.pub!指纹已经存在.请为每个Heroku帐户使用一个ssh密钥

请帮我!这太令人沮丧了,我不知道出了什么问题!谢谢

Gio*_*lzo 288

我有同样的问题,我跟着这篇文章和同类的其他人没有成功: - ((

最后,我找到了解决方案:我必须在我的机器中添加新的rsa标识!

所以,首先我创建了一个新的rsa密钥:

ssh-keygen -t rsa -C "giordano.scalzo[at]gmail.com" -f  ~/.ssh/id_rsa_heroku
Run Code Online (Sandbox Code Playgroud)

然后将它添加到我的机器上

ssh-add ~/.ssh/id_rsa_heroku
Run Code Online (Sandbox Code Playgroud)

最后,到了Heroku

heroku keys:add ~/.ssh/id_rsa_heroku.pub
Run Code Online (Sandbox Code Playgroud)

之后,

git push heroku master
Run Code Online (Sandbox Code Playgroud)

像魅力一样工作!

希望这可以帮助.

  • 这对我来说非常接近.但还有一件事.我有两个heroku帐户.第一个为我的机器添加了我的默认SSH密钥.无论我尝试修复我的第二个帐户,我都不会在第一个帐户中删除默认密钥.SSH-AGENT默认发送第一个密钥,导致此问题.修复方法是为每个帐户创建heroku(不是默认值)的特定键 (47认同)
  • 就我个人而言,我做了相当于`ssh-add~/.ssh/id_rsa_heroku`虽然我的是`ssh-add~/.ssh/identity.heroku.foo`,因为我也使用[https:// github .com/ddollar/heroku-accounts](https://github.com/ddollar/heroku-accounts)(Heroku的多账户经理). (14认同)
  • 我和@TomCarchrae有同样的问题.我注销了似乎永久性地被`heroku logout`破坏的帐户,登录到另一个帐户,并从该帐户中删除了默认的RSA密钥.之后,我能够使用这个新生成的密钥推送. (13认同)
  • 您可以通过在〜/ .ssh/config中为heroku.com添加指向您想要的密钥的主机条目来影响发送的密钥.这是一个快速解决方案,因为它一直试图使用我的默认密钥和失败.但是,对于多个帐户,这可能无济于事. (7认同)

tow*_*lin 61

我也有多个密钥和多个heroku帐户,所以我每隔几个月就会遇到这个问题.如上所述Giordano Scalzo,Tom Carchrae和user664833,主要问题是ssh-agent,您可以使用该ssh-add命令控制它.手册页(man ssh-add)实际上非常简洁明了,所以请查看.

您可以列出ssh​​-agent知道的所有密钥:

ssh-add -l
Run Code Online (Sandbox Code Playgroud)

您可以删除ssh-agent知道的所有密钥:

ssh-add -D
Run Code Online (Sandbox Code Playgroud)

或删除特定的密钥

ssh-add -d ~/.ssh/id_rsa_example_key_file_use_your_own
Run Code Online (Sandbox Code Playgroud)

别担心!您实际上并没有删除密钥,只是更改了ssh-agent自动尝试使用的密钥,例如,当您尝试推送到heroku时.根据需要添加和删除密钥很容易,所以对我来说,当我对这个问题感到沮丧时,解决它的最简单方法是删除所有密钥并仅添加回我想要使用的密钥.

ssh-add -D
ssh-add ~/.ssh/id_rsa_example_use_this_one_i_mean_it
Run Code Online (Sandbox Code Playgroud)


Dan*_*ore 38

您的计算机有一个SSH密钥,但该SSH密钥与另一个Heroku帐户相关联.

如果您需要在同一台计算机上同时使用这两个帐户,则应在计算机上创建一个新的SSH密钥并将其上传到Heroku:

$ ssh-keygen
Run Code Online (Sandbox Code Playgroud)

当提示问你时,请确保将其保存为'/Users/User/.ssh/new_id_rsa.pub'.

$ heroku keys:add /Users/User/.ssh/new_id_rsa.pub 
Run Code Online (Sandbox Code Playgroud)

然后,您需要添加一个备用主机为heroku.com~/.ssh/config:

Host heroku-alt
HostName heroku.com
IdentityFile ~/.ssh/new_id_rsa
Run Code Online (Sandbox Code Playgroud)

然后.git/config在项目中更新以使用主机别名:

[remote "heroku"]
  url = git@heroku-alt:myapp.git
  fetch = +refs/heads/*:refs/remotes/heroku/*
Run Code Online (Sandbox Code Playgroud)

通过之间进行选择heroku,并heroku-alt在偏远.git/config的具体项目,你可以管理文件的项目中使用的凭证.

  • 优秀!这种技术非常优雅! (3认同)

pix*_*rth 14

这是一个非常明确的解释,缺少Heroku文档或问题的其他答案.至少所有信息似乎都没有出现在任何一个地方.它还让您以帐户工具不具备的方式理解问题.

Heroku以两种方式识别您:

第一个是.git/config

[heroku]
    account = acccount_name
Run Code Online (Sandbox Code Playgroud)

这似乎让您使用执行基本操作 heroku

heroku识别你的第二种方式是使用ssh(git push)的任何操作.Heroku将通过您的ssh密钥识别您,如下所述:https: //devcenter.heroku.com/articles/keys

此密钥对用于强加密,并在推送代码更改时唯一标识您为开发人员.

因此,当您使用ssh时,您使用的每个heroku帐户都必须向heroku发送不同的密钥.按照任何教程创建您的ssh密钥.

关键是让SSH为每个Heroku帐户使用不同的密钥.你是如何配置的?你需要做两件事:

1)您需要创建一个"虚拟"域,您的.ssh/config将拦截并重新配置.这将告诉ssh你想要的"实际"域名,以及使用哪个特殊的ssh密钥.

Host heroku.my_unique_key
  HostName heroku.com
  IdentityFile ~/.ssh/identity.heroku.my_unique_key
  IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)

2)更改你的.git/config以在使用git push时使用它.而不是heroku.com,使用您在.ssh/config中设置的虚拟域

[remote "heroku"]
    url = git@heroku.com.git


[remote "heroku"]
    url = git@heroku.my_unique_key:myapp.git
Run Code Online (Sandbox Code Playgroud)

就是这样:)有点复杂,有点简单.我花了3年的时间撞墙,试错了才发现这个信息.它应该在某处清楚地记录下来,但至少它是一个开始.


ale*_*mur 9

你将需要创建新的密钥并添加它们

运行后指定新文件名

ssh-keygen
Run Code Online (Sandbox Code Playgroud)

然后(在我的情况下)

heroku keys:add /home/alex/.ssh/alex_heroku_rsa.pub
Run Code Online (Sandbox Code Playgroud)