git 由于密钥指纹无法推送到 Heroku
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8786564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot push to Heroku because key fingerprint
提问by mre
I am new to Rails, and I was trying to deploy a very simple app to Heroku. This is the second app that I deploy, and the first one I was able to do it just fine. However I am having some issues with this one. Whenever I "git push heroku master", I get this error:
我是 Rails 的新手,我试图将一个非常简单的应用程序部署到 Heroku。这是我部署的第二个应用程序,也是我能够很好地完成的第一个应用程序。但是,我对此有一些问题。每当我“ git push heroku master”时,我都会收到此错误:
! Your key with fingerprint xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx is not authorized to >access my_heroku_app.
fatal: The remote end hung up unexpectedly
!您的指纹为 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx 的密钥无权访问 my_heroku_app。
致命:远端意外挂断
I have tried to manage my keys after logging in heroku. If I type in my console "heroku keys", then I get:
登录heroku后,我尝试管理我的密钥。如果我在控制台中输入“ heroku keys”,则会得到:
No keys for myemailaddress.
myemailaddress 没有键。
However, If I run the comand "heroku keys:add" I get
但是,如果我运行命令“ heroku keys:add”我得到
Found existing public key: /Users/michele/.ssh/id_rsa.pub Uploading ssh public key /Users/michele/.ssh/id_rsa.pub ! Fingerprint already exists. Please use one ssh key per Heroku account
找到现有的公钥:/Users/michele/.ssh/id_rsa.pub Uploading ssh public key /Users/michele/.ssh/id_rsa.pub !指纹已经存在。请为每个 Heroku 帐户使用一个 ssh 密钥
Please help me! This is soo frustating, I have no idea what's wrong! Thank you
请帮我!这太令人沮丧了,我不知道出了什么问题!谢谢
回答by Giordano Scalzo
I had the same problem, I followed this post and others of the same kind without success :-((
我遇到了同样的问题,我按照这篇文章和其他同类文章没有成功:-(
Finally, I found the solution: I had to add my new rsa identity in my machine!
最后,我找到了解决方案:我必须在我的机器中添加我的新 rsa 身份!
So, first of all I created a new rsa key:
所以,首先我创建了一个新的 rsa 密钥:
ssh-keygen -t rsa -C "giordano.scalzo[at]gmail.com" -f ~/.ssh/id_rsa_heroku
then added it to my machine
然后将它添加到我的机器上
ssh-add ~/.ssh/id_rsa_heroku
and, finally, to Heroku
最后,到 Heroku
heroku keys:add ~/.ssh/id_rsa_heroku.pub
After that,
在那之后,
git push heroku master
worked like a charm!
像魅力一样工作!
Hope this helps.
希望这可以帮助。
回答by towynlin
I, too have multiple keys and multiple heroku accounts, so I come across this problem every few months. As mentioned Giordano Scalzo, Tom Carchrae, and user664833, the main problem is ssh-agent, which you control using the ssh-add
command. The man page (man ssh-add
) is actually pretty clear and concise, so check it out.
我也有多个密钥和多个 heroku 帐户,所以我每隔几个月就会遇到这个问题。正如 Giordano Scalzo、Tom Carchrae 和 user664833 所提到的,主要问题是 ssh-agent,您可以使用ssh-add
命令来控制它。手册页 ( man ssh-add
) 实际上非常清晰简洁,因此请查看一下。
You can list all the keys that ssh-agent knows about with:
您可以列出 ssh-agent 知道的所有密钥:
ssh-add -l
You can delete all the keys that ssh-agent knows about with:
您可以删除 ssh-agent 知道的所有密钥:
ssh-add -D
Or delete a specific key with
或者删除一个特定的键
ssh-add -d ~/.ssh/id_rsa_example_key_file_use_your_own
Don't worry! You aren't actually deleting the keys, only changing which ones ssh-agent automatically tries to use, for example, when you try to push to heroku. It's easy to add and delete keys as needed, so for me, when I get frustrated by this problem, the easiest way to fix it is to delete all the keys and add back in only the one I want to use at the moment.
别担心!您实际上并没有删除密钥,只是更改了 ssh-agent 自动尝试使用的密钥,例如,当您尝试推送到 heroku 时。根据需要添加和删除键很容易,所以对我来说,当我对这个问题感到沮丧时,最简单的解决方法是删除所有键,然后只添加我目前想要使用的键。
ssh-add -D
ssh-add ~/.ssh/id_rsa_example_use_this_one_i_mean_it
回答by Daniel X Moore
Your computer has an SSH key, but that SSH key is associated with another Heroku account.
您的计算机有一个 SSH 密钥,但该 SSH 密钥与另一个 Heroku 帐户相关联。
If you need to use both accounts for different applications on the same computer you should make a new SSH key on your machine and upload it to Heroku:
如果您需要在同一台计算机上将两个帐户用于不同的应用程序,您应该在您的机器上创建一个新的 SSH 密钥并将其上传到 Heroku:
$ ssh-keygen
Make sure to save it as '/Users/User/.ssh/new_id_rsa.pub' when the prompt asks you.
当提示询问您时,请确保将其保存为“/Users/User/.ssh/new_id_rsa.pub”。
$ heroku keys:add /Users/User/.ssh/new_id_rsa.pub
You then need to add an alternate host for heroku.com
to your ~/.ssh/config
:
然后,您需要为heroku.com
您的~/.ssh/config
:添加一个备用主机:
Host heroku-alt
HostName heroku.com
IdentityFile ~/.ssh/new_id_rsa
And then update the .git/config
in your project to use the host alias:
然后更新.git/config
项目中的 以使用主机别名:
[remote "heroku"]
url = git@heroku-alt:myapp.git
fetch = +refs/heads/*:refs/remotes/heroku/*
By choosing between heroku
and heroku-alt
in the remote of the .git/config
files of specific projects you can manage which projects use which credentials.
通过之间进行选择heroku
,并heroku-alt
在偏远.git/config
的具体项目,你可以管理的项目中使用的凭证文件。
回答by pixelearth
Here's a very clear explanation that is lacking from ther Heroku documentation or other answers to the question. At least all the info doesn't seem to appear in any one place. It also let's you understand the problem in a way that the accounts tool doesn't.
这是 Heroku 文档或该问题的其他答案中缺少的非常明确的解释。至少所有信息似乎都没有出现在任何一个地方。它还可以让您以帐户工具没有的方式了解问题。
Heroku identifies you in 2 ways:
Heroku 通过两种方式识别您:
The first is in .git/config
第一个在 .git/config
[heroku]
account = acccount_name
This seems to let you perform basic operations using heroku
这似乎可以让您使用 heroku
The second way heroku identifies you is by any operation that uses ssh (git push). Heroku will identify you by your ssh key, as stated here: https://devcenter.heroku.com/articles/keys
heroku 识别您的第二种方式是通过任何使用 ssh (git push) 的操作。Heroku 将通过您的 ssh 密钥识别您,如下所述:https: //devcenter.heroku.com/articles/keys
This keypair is used for the strong cryptography and that uniquely identifies you as a developer when pushing code changes.
此密钥对用于强加密,并在推送代码更改时唯一地将您标识为开发人员。
So each heroku account that you work on will have to send a different key to heroku when using ssh. Follow any tutorial to create your ssh keys.
因此,在使用 ssh 时,您使用的每个 heroku 帐户都必须向 heroku 发送不同的密钥。按照任何教程创建您的 ssh 密钥。
The key is getting SSH to use different keys for each Heroku account. How do you do configure this? You'll need to do 2 things:
关键是让 SSH 为每个 Heroku 帐户使用不同的密钥。你如何配置这个?你需要做两件事:
1) You'll need to make a 'dummy' domain that your .ssh/config will intercept and reconfigure. This will tell ssh the 'actual' domain you want, and which special ssh key to use.
1) 您需要创建一个“虚拟”域,您的 .ssh/config 将拦截并重新配置该域。这将告诉 ssh 您想要的“实际”域,以及要使用的特殊 ssh 密钥。
Host heroku.my_unique_key
HostName heroku.com
IdentityFile ~/.ssh/identity.heroku.my_unique_key
IdentitiesOnly yes
2) Change your .git/config to use that when using git push. Instead of heroku.com, use the dummy domain you set in your .ssh/config
2) 更改您的 .git/config 以在使用 git push 时使用它。使用您在 .ssh/config 中设置的虚拟域,而不是 heroku.com
[remote "heroku"]
url = [email protected]
[remote "heroku"]
url = [email protected]_unique_key:myapp.git
That's it :) A bit complicated and a bit simple at the same time. It has taken me 3 years of banging my head against the wall and trial and error to discover this info. It should be clearly documented somewhere, but at least it's a start.
就是这样:) 有点复杂,同时又有点简单。我花了 3 年的时间把头撞在墙上,反复试验才发现这些信息。它应该在某处清楚地记录下来,但至少它是一个开始。
回答by alemur
youn will need to create new keys and add those
您将需要创建新密钥并添加这些密钥
specify a new file name after running
运行后指定新文件名
ssh-keygen
then (in my case)
然后(就我而言)
heroku keys:add /home/alex/.ssh/alex_heroku_rsa.pub
回答by M. Scott Ford
In my case, heroku keys
already had the correct key listed. So, all I had to do was run ssh-add /path/to/that/key
and then everything started working fine.
就我而言,heroku keys
已经列出了正确的密钥。所以,我所要做的就是运行ssh-add /path/to/that/key
,然后一切开始正常运行。
回答by Benjamin
I have the same issue last week. This linked helped me out. I hope it helps you out a little. http://devcenter.heroku.com/articles/keys
我上周有同样的问题。这个链接帮助了我。我希望它对你有所帮助。http://devcenter.heroku.com/articles/keys
回答by Fabio CR
I also have two Heorku accounts and as a work-around I "invited" my main account (the one whose key is used automatically by Heroku) as a collaborator to my project.
我还有两个 Heorku 帐户,作为一种解决方法,我“邀请”了我的主帐户(Heroku 自动使用其密钥的那个)作为我项目的合作者。
回答by Rails beginner
Just wan′t to add the solution for Windows users.
只是不想为 Windows 用户添加解决方案。
First download "Putty Key generator"
Create a key with it OBS you need to move your mouse ower the blank area to generate randomness.
Save your keys, just remeber to rename your key to [name].pub
Run
heroku keys:add
in terminal!
首先下载“腻子密钥生成器”
用它创建一个键 OBS 您需要将鼠标移动到空白区域以生成随机性。
保存您的密钥,请记住将您的密钥重命名为 [name].pub
heroku keys:add
在终端运行!
回答by gfhuertac
In my case the problem was the ssh version I was using. I just set the GIT_SSH environment variable to another ("GIT_SSH=/usr/bin/ssh") and everything worked OK for me.
就我而言,问题是我使用的 ssh 版本。我只是将 GIT_SSH 环境变量设置为另一个(“GIT_SSH=/usr/bin/ssh”),一切正常。