13

Edit #3

Updating this at the top because it solved my issue and gave me a good troubleshooting step I didn't know about (and could save you some time, too)

Try getting the output of ssh -vvv git@heroku.com. For me, ssh was getting hung up on trying keys in /c/Program Files (x86)/Emacs/.ssh when my public key was in /c/Users/NumberOverZero/.ssh

Deleting the Emacs ssh folder (which was empty) fixed my issue since ssh would then check my Users .ssh folder.


I'm getting Permission denied (publickey) when trying to git push heroku master.

A few things that makes this different from the posts below:

  • I have ssh working for github
  • I was able to successfully push to heroku last night
  • Since that push, I've made a single-line change to one js file, and committed and pushed. There have been no other changes.

The closest I could find was this post:

git clone heroku ssh permission denied

I've looked through the related issues (there's quite a few):

git push heroku master Permission denied (publickey). fatal: The remote end hung up unexpectedly
git push heroku master permission denied
git clone heroku ssh permission denied
https://stackoverflow.com/questions/13059076/git-push-permission-denied-publickey-windows-xp
heroku - rails - Permission denied (publickey)

I've tried:

  1. heroku keys:clear
    heroku keys:add
    
  2. heroku keys:clear
    *delete every key in .ssh*
    heroku keys:add
    
  3. *delete my application on heroku*
    heroku keys:clear        
    heroku login (adds key for me)
    heroku create
    git push heroku master
    fails
    
  4. *delete the app on heroku*
    delete keys in .ssh
    heroku keys:clear
    copy all files into a new repository
    push new repository to github successfully
    heroku login (adds github key for me)
    heroku create
    git push heroku master
    fails
    
  5. *delete the app on heroku*
    heroku keys:clear
    heroku login (adds key for me)
    heroku create
    heroku git:clone app app
    fails
    

Any ideas? I've gone through all of the steps in the linked SOs - most of which were just people not running heroku:add or setting up ssh keys (which I've done in each of these).

I let heroku take the wheel most of the time, (instead of directly creating ssh keys) assuming that the built-in commands would do what they needed when there were no ssh keys present. It seems not.

EDIT: And now that I deleted the app, the new relic addon is alarming that the website is down. Trying to log in through their website asks me to log in through heroku. Which I can't find a way to do, since the app is gone. Is there a way to delete that addon now that I can't get to the app? heroku addons gives an error, so I don't think I'm getting to it through there.

EDIT #2: Added another step I tried - moved files into new repository and push to new application.

Community
  • 1
  • 1
  • are you using heroku gem or the toolbet? what is your OS? have you tried after some time? maybe it was some api errors? – Nicos Karalis Feb 05 '13 at 18:39
  • I used the auto installer for win7, which I believe is toolbelt. I tried 11 hours ago and 2 hours ago (multiple times each). I checked their status and didn't see any API issues, but there was something (roughly) an hour before I tried the first push that failed, I think. –  Feb 05 '13 at 19:18
  • @NumberOverZero - Could you elaborate on just how the output helped you? The wall of debug text emitted by -vvv is indecipherable. – Constablebrew May 19 '14 at 23:05
  • 1
    heroku keys:clear , heroku keys:add did it – Aladdin Mhemed May 24 '14 at 17:11

3 Answers3

9

I had the same problem for Windows 7 box and found the solution here: http://www.gmarwaha.com/blog/2011/05/18/heroku-trouble-with-windows-and-ssh-keys/

Solution: Typically once you create the keys as mentioned above, two files – “id_rsa” and “id_rsa.pub” – are stored in the “.ssh” folder within the user’s home folder. If you are working with linux that seems to be good enough. But for the windows version of git that doesn’t seem to cut it. It wants the keys to be stored inside the “.ssh” folder within the “msysgit” installation folder as well. If you don’t find a “.ssh” folder inside the “msysgit” installation folder, feel free to create one. Once you drop these two key files there and repeat the entire process, everything went as smooth and my application got deployed in the heroku cloud and the world is again a better place to live in.

In my case, I have to find where git.exe was installed, which is C:\Program Files\Git\. So here are the steps:

  1. Create .ssh folder inside C:\Program Files\Git\
  2. Copy id_rsa and id_rsa.pub from your home folder (C:\Users\username\.ssh\) to C:\Program Files\Git\.ssh\.
  3. Try again with C:\dev\heroku\sample-app> git push heroku master.
3

Nice job linking to all the other things you've looked at and tried! (that will improve the responses you get, but still you should be prepared for a lot of 'have you tried...', and 'maybe it's ...' because this is a system/env issue that isn't on the normal flow)

You might have had something working in your local terminal session that has since been lost. (I've had this happen a bunch of times)

Things it might be:

  1. your ssh keys on heroku
  2. your ability to push up to heroku from that computer/network
  3. something about your git repo

I ran into this once and it was driving me crazy. I hopped on my (FREE) cloud9 account, cloned some simple rails app from github and pushed it out to heroku, which helped me prove that my heroku account was fine, heroku itself was fine, but my local laptop had some issues in my configuration. I think the issue was my username, but I don't remember. (moving to a different env and starting from scratch helped me realize the issue though)

J_McCaffrey
  • 1,455
  • 12
  • 15
  • Thanks for the response. (1) If it is something about my ssh keys on heroku, what is `heroku keys:clear` not taking care of? Also, is there another way to manage their version of my keys? (2) Certainly a possibility. I can try this with cloud9 later I guess. (3) I tried copying everything into a new repo, pushed that successfully to github, and then deleted my app on heroku and tried to upload the new repo to a new heroku app. I'll add this to the list, thanks. –  Feb 05 '13 at 19:16
  • Update: I tried pushing from cloud9 and it succeeded, so I'll try a full reinstall of the toolbelt and see what happens. The push from c9 is showing a repo size of 145mb though, when it's only ~1-2 on github (with less than a dozen commits, since I made a new repo in test #4). I'll accept this once I see what happens with a reinstall. Thanks for the help! –  Feb 05 '13 at 20:27
  • Remember that slug size != repo size. The slug has your code plus any dependencies and any language runtimes too. If your're using a complied language like Java, it will also have the compiled source. – ryanbrainard Feb 06 '13 at 01:23
  • I'm not sure what you mean - my repo size is displaying as 145MB, not slug size. Slug size is 31.4MB. I know there was a comment about repository size being larger on heroku than locally, but 2 orders of magnitude seems like a lot. Is there any way to have them blow away the whole thing and fully upload my repository again? –  Feb 06 '13 at 01:58
  • I'm marking this as accepted since The cloud9 advice helped me diagnose the problem, but I still don't know what caused this. I'm back to a working state, so that's good. My repo size still shows abnormally large... –  Feb 10 '13 at 21:29
0

The main reason you get this message is because you do not have ssh-keygen added to your environment variables.

This command is located in the bin-directory of Git program files.

You should add that bin directory to your environment variables.