Cannot push to Heroku because key fingerprint

GitHerokuSshGit Push

Git Problem Overview


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

Git Solutions


Solution 1 - Git

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!

So, first of all I created a new rsa key:

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 keys:add ~/.ssh/id_rsa_heroku.pub

After that,

git push heroku master

worked like a charm!

Hope this helps.

Solution 2 - Git

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.

You can list all the keys that ssh-agent knows about with:

ssh-add -l

You can delete all the keys that ssh-agent knows about with:

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-add -D
ssh-add ~/.ssh/id_rsa_example_use_this_one_i_mean_it

Solution 3 - Git

Your computer has an SSH key, but that SSH key is associated with another Heroku account.

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-keygen

Make sure to save it as '/Users/User/.ssh/new_id_rsa.pub' when the prompt asks you.

$ 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:

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:

[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.

Solution 4 - Git

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 = [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.

Solution 5 - Git

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

Solution 6 - Git

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

Solution 7 - Git

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.

Solution 8 - Git

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.

Solution 9 - Git

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!

Solution 10 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmreView Question on Stackoverflow
Solution 1 - GitGiordano ScalzoView Answer on Stackoverflow
Solution 2 - GittowynlinView Answer on Stackoverflow
Solution 3 - GitDaniel X MooreView Answer on Stackoverflow
Solution 4 - GitpixelearthView Answer on Stackoverflow
Solution 5 - GitakmurView Answer on Stackoverflow
Solution 6 - GitBenjaminView Answer on Stackoverflow
Solution 7 - GitM. Scott FordView Answer on Stackoverflow
Solution 8 - GitFabio CRView Answer on Stackoverflow
Solution 9 - GitRails beginnerView Answer on Stackoverflow
Solution 10 - GitgfhuertacView Answer on Stackoverflow