Cannot push to Heroku because key fingerprint

2020-01-24 02:00发布

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:

! 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

I have tried to manage my keys after logging in heroku. If I type in my console "heroku keys", then I get:

No keys for myemailaddress.

However, If I run the comand "heroku keys:add" I get

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

Please help me! This is soo frustating, I have no idea what's wrong! Thank you

10条回答
等我变得足够好
2楼-- · 2020-01-24 02:24

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 identifies you in 2 ways:

The first is in .git/config

[heroku]
    account = acccount_name

This seems to let you perform basic operations using 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

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.

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:

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.

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

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


[remote "heroku"]
    url = git@heroku.my_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楼-- · 2020-01-24 02:24

Just wan´t to add the solution for Windows users.

  1. First download "Putty Key generator"

  2. Create a key with it OBS you need to move your mouse ower the blank area to generate randomness.

  3. Save your keys, just remeber to rename your key to [name].pub

  4. Run heroku keys:add in terminal!

查看更多
Root(大扎)
4楼-- · 2020-01-24 02:26

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.

查看更多
可以哭但决不认输i
5楼-- · 2020-01-24 02:34

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.

查看更多
登录 后发表回答