2

I am getting below error while creating app and deploying in heroku using below command

sudo git push heroku master

Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I tried all the possible scenarios creating new ssh key , giving admin rights to folder, deleting git remote for heroku and adding it again etc Steps followed by me: 1) git init
2) git add .
3) git commit -m "Initial Commit"
4) heroku login
5) heroku create
6) sudo git push heroku master
Usually when we create new heroku project using "heroku create" it will create new project and that heroku URL is set as heroku GIT remote URL, but that also not happening everytime i am doing it manually.
May be this also due to that same issue i guess...
Below is my detailed error
ponvino@ponvino-desktop:~/RubyWorkspace/prod/theScholarsPage$ sudo mv ~/.ssh/ /.ssh_backup ponvino@ponvino-desktop:~/RubyWorkspace/prod/theScholarsPage$ heroku keys:add
Could not find an existing public key.
Would you like to generate one? [Yn] y
Generating new SSH public key.
Uploading SSH public key /home/ponvino/.ssh/id_rsa.pub... done
ponvino@ponvino-desktop:~/RubyWorkspace/prod/theScholarsPage$ git push heroku master
The authenticity of host 'heroku.com (50.19.85.156)' can't be established.
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,50.19.85.156' (RSA) to the list of known hosts.
Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

Please help me

Thanks in Advance,

8
  • you need to upload your public key on heroku Commented Jul 7, 2013 at 10:14
  • yes while doing heroku login it got automatically uploaded. I verified the uploaded key using heroku keys it is correct only.. Thanks Commented Jul 7, 2013 at 10:28
  • what os you on? also post the output of heroku keys:add Commented Jul 7, 2013 at 10:35
  • @GaurishSharma i am using Ubuntu 13.04 .. This is my output heroku keys:add Found the following SSH public keys: 1) id2_rsa.pub 2) id_dsa.pub 3) id_rsa.pub Which would you like to use with your Heroku account? 2 Uploading SSH public key /home/ponvino/.ssh/id_dsa.pub...done Commented Jul 7, 2013 at 10:44
  • Maybe there is no remote named "heroku". What do you see when you run git remote -v? Commented Jul 7, 2013 at 12:05

4 Answers 4

6

Check that your ssh key is loaded:

ssh-add -l

If not:

ssh-add ~/.ssh/your_private_key

Try again to push to heroku

Sign up to request clarification or add additional context in comments.

3 Comments

Yes it is already loaded . ssh-add -l is returning my SSH keys. Thanks
Finally this is the right answer.. I first tried ssh-add -l it returned my keys so i didn't tried your second step but atlast it only helped me Thank you very much
you welcome. If you need more information on ssh-add command, look here developer.apple.com/library/mac/documentation/Darwin/Reference/…
4

You should generate pair of keys and add your public key to your heroku account. More info: https://devcenter.heroku.com/articles/keys

ssh-keygen -t rsa

and then:

heroku keys:add

should be enough.

Comments

1

If nothing works even after trying the above solutions. do this

$ mv ~/.ssh/ ~/.ssh_backup
$ heroku keys:add
$ git push heroku master

5 Comments

It is creating new SSH key and uploading it properly but again i am getting same error... Thanks
interesting. did you run git with sudo? can you post the full output?
posted full output in main post... i even tried git with sudo but not working ... Thanks
you should never use git sudo. Further, also post the output of git remote -v & heroku login? lastly, also post the output of heroku apps, does it contain your app name?
Hi, I got solution from this, Thanks for your help...After adding SSH identity it is working.. ripan27.wordpress.com/2010/04/01/… Thanks
0

Almost same problem was asked and answered in the link below.

Try it

1 Comment

That pblm is different see the differnce in error there "fatal: The remote end hung up unexpectedly" For me "fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists" Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.