I've searched around for many hours on end looking to a solution to my seemingly easy-to-fix problem. It's not that my search turned up nothing, it's that my search turned up so many different solutions -none of which have worked.
Anyways, I am simply unable to push, pull, or fetch from my Heroku repository from my Mac. Every attempt gives me (as if it's mocking me) the following error:
'Permission denied (publickey). fatal: Could not read from remote repository.'
I've tried (and re-tried) to fix it in many different ways. As I've said, I've spent a good chunk of the last two days searching around for an answer. Here are some of the things I've tried:
- heroku keys:clear followed by heroku keys:add
- Regenerating an ssh key on my own with 'ssh-keygen -t rsa'
- Clearing out my .ssh directory, followed by heroku keys:clear, followed by generating an ssh key
- Deleting my app on heroku and recreating one (fortunately not much was on there)
I can fetch from my GitHub repository fine, so I know it's not network connectivity (pinging heroku also works).
As a makeshift solution (that I hope doesn't turn into a permanent one), I've logged in to my Ubuntu Amazon AWS ec2 instance. Pulling and pushing to and from Heroku works perfectly. For this reason, I still feel as if the problem lies with the ssh key on my Mac. Both keys show up under my Heroku account. Does the email address at the end of the key matter?
EDIT: I can push and pull from GitHub fine (I'm not using ssh, however), so why not Heroku?
At this point I'm willing to try anything. Thanks!
I had the exact same error (on windows 7) and the cause was different. I solved it in a different way so I thought I'd add the cause and solution here for others.
Even though the error seemed to point to heroku really the error was saying
"Heroku can't get to the git repository"
. I swore I had the same keys on all the servers because I created it and uploaded it to one after the other at the same time.After spending almost a day on this I realized that because git was only showing me the fingerprint and not the actual key. I couldn't verify that it's key matched the one on my HD or heroku. I looked in the known hosts file and guess what... it shows the keys for each server and I was able to clearly see that the git and heroku public keys did not match.
1) I deleted all the files in my key folder, the key from github using their website, and the key from heroku using git bash and the command
heroku keys:clear
2) Followed github's instructions here to generate a new key pair and upload the public key to git
3) using
git bash-
heroku keys:add
to upload the same key to heroku.Now
git push heroku master
works.what a nightmare, hope this helped somebody.
Bryan
I know this has already been answered. But I would like to add my solution as it may helpful for others in the future..
A common key error is:
Permission denied (publickey)
. You can fix this by usingkeys:add
to notify Heroku of your new key.In short follow these steps: https://devcenter.heroku.com/articles/keys
First you have to create a key if you don't have one:
Second you have to add the key to Heroku:
you need to create a new ssh key by typing the following - ssh-keygen -t rsa
Then you need to add: - heroku keys:add
Then if you type - heroku open
The problem has been solved.
It worked for me anyway, you could give it a try...
I got the same error, and because I have 4 ssh-keys, so I tried follow:
then, four options show:
I choose 3), the newest one
Then, I fix the error.
The problem I was having is that I was only using https for my GitHub account. I needed to make sure that my GitHub account was setup for ssh access and that GitHub and heroku were both using the same public keys. These are the steps I took:
Navigate to the ~/.ssh directory and delete the id_rsa and id_rsa.pub if they are there. I started with new keys, though it might not be necessary.
Login to heroku, create a new site and add your public keys:
i had the same case on linux ubuntu and just fixed it, it seems that OS was confused between the /root/.ssh/ and home/user/.ssh/ dir, what i did was:
heroku keys
heroku keys:clear
heroku keys:add
now in here if heroku couldn't find a key and asked to generate one right no, and this mean you have the same issue as mine, do the add command like thisheroku keys:add /root/.ssh/id_rsa.pub
the path that you'll add will be the one that you got in step 2.git push heroku master
now