Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push heroku master Permission denied (publickey). fatal: The remote end hung up unexpectedly

Tags:

git

heroku

Please excuse a bit of frustration, which I will try to keep in check since Heroku is using SO as their customer support (which I think it shoddy to say the least).

For the last five hours I have been trying to get an application to publish, but invariably something goes wrong with the keys. I've read dozens of articles and tried tip after tip in an effort to figure out where, in the stupid, completely opaque process Heroku is screwing up.

My use case is not that difficult: I have created a new keypair for my heroku apps. I have set that key to be my key:

  > heroku keys   === [email protected] Keys   ssh-rsa AAAAB3NzaC...avOqfA7ZBd [email protected] 

I can log in and "create" an application (stupid name, since it seems to be creating a git repo, not any sort of app) without problem. But every *freaking* time I try to push my app, I get:

  > git push heroku master   Permission denied (publickey).   fatal: The remote end hung up unexpectedly 

I have no insight into WTF is going on with it; I'm just stuck banging my head against a keyboard with no recourse but to hope the almighty god of Google can answer it. And google isn't answering it (well, let me take that back, I've seen about a dozen ways to answer this).

For a system that is supposed to be easy, this is a joke. I like the idea of Heroku, but after taking five our to get absolutely nothing done, I'm thinking maybe it is the wrong choice.

like image 217
Travis Jensen Avatar asked Aug 30 '12 22:08

Travis Jensen


People also ask

What is permission denied (publickey) fatal?

Permission denied (publickey). fatal: The remote end hung up unexpectedly while pushing back to git repository 82 git push: permission denied (public key) 85 git push heroku master Permission denied (publickey). fatal: The remote end hung up unexpectedly 28

What causes Git publickey error when not run in idle?

Python script causes git publickey error when not run in IDLE -1 Permission denied (publickey) when using SSH with Git 0 Permission denied (publickey) on push into remote git-server

How do I fix Git push fails?

Refer to the resolution of Git push fails - client intended to send too large chunked body for ngnix reverse proxy configuration. Increase this parameter to the largest individual file size of your repo. Bypass the outbound proxy as explained on Can't clone or pull due to a git outbound proxy Last modified on Feb 26, 2016

Why is my Remote under 'origin' and not 'Heroku'?

Assuming an existing heroku app where your remote is under 'heroku' and not 'origin', this causes a lot of confusion. Permission denied (publickey). The README should make it clearer that the 'heroku accounts:set foo' command adds a remote to 'origin' and not 'heroku' (as is standard with most heroku git repos).


2 Answers

Your heroku key and github keys are not in sync.

  • Determine which key you want to use (recommend creating a new one ie heroku_rsa).

  • Add the key to github.

  • Add the same key to heroku using: heroku keys:add

like image 27
Robert Christian Avatar answered Oct 20 '22 01:10

Robert Christian


There are a variety of solutions around the web. I will try to condense the available options into one post. Please try your connection again after every step.

  • Step 1: Attempt adding you public key to Heroku

    heroku keys:add ~/.ssh/id_rsa.pub // or just heroku keys:add and it will prompt you to pick one of your keys 
  • Step 2: Generate a new set of SSH keys, then attempt the first step again

    https://help.github.com/articles/generating-ssh-keys

  • Step 3: Verify and/or modify your config file

    vim ~/.ssh/config  Host heroku.com Hostname heroku.com  Port 22  IdentitiesOnly yes  IdentityFile ~/.ssh/id_rsa    <--- Should be your public SSH key TCPKeepAlive yes  User [email protected] 
  • Step 4: Remove the heroku remote from git, the recreate the connection, adding the remote via heroku create will only be an option for new repositories. Be sure to delete your old repo that you originally attempted to create

     $ git remote rm heroku  $ heroku create 
  • Step 5: Reinstall Heroku Toolkit

like image 118
jquintana Avatar answered Oct 19 '22 23:10

jquintana