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,

victor
  • 153
  • 2
  • 14
  • you need to upload your public key on heroku – CuriousMind Jul 07 '13 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 – victor Jul 07 '13 at 10:28
  • what os you on? also post the output of `heroku keys:add` – CuriousMind Jul 07 '13 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 – victor Jul 07 '13 at 10:44
  • Maybe there is no remote named "heroku". What do you see when you run `git remote -v`? – Wizard of Ogz Jul 07 '13 at 12:05
  • What happens if you try the last step without "sudo"? – Wizard of Ogz Jul 07 '13 at 12:08
  • @ponvino see my answer. it will fix your problem – CuriousMind Jul 07 '13 at 12:10
  • @Wizard of Ogz When i try without sudo i got two more line error in addition to that **"Warning: Permanently added the RSA host key for IP address '50.19.85.132' to the list of known hosts. Agent admitted failure to sign using the key."** git remote -v is returning proper remote address.. Thanks – victor Jul 07 '13 at 12:30

4 Answers4

7

Check that your ssh key is loaded:

ssh-add -l

If not:

ssh-add ~/.ssh/your_private_key

Try again to push to heroku

Pierre-Louis Gottfrois
  • 17,561
  • 8
  • 47
  • 71
  • Yes it is already loaded . **ssh-add -l** is returning my SSH keys. Thanks – victor Jul 07 '13 at 10:40
  • 1
    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 – victor Jul 07 '13 at 14:39
  • you welcome. If you need more information on `ssh-add` command, look here https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ssh-add.1.html – Pierre-Louis Gottfrois Jul 08 '13 at 07:14
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.

Marek Lipka
  • 50,622
  • 7
  • 87
  • 91
1

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

$ mv ~/.ssh/ ~/.ssh_backup
$ heroku keys:add
$ git push heroku master
CuriousMind
  • 33,537
  • 28
  • 98
  • 137
  • It is creating new SSH key and uploading it properly but again i am getting same error... Thanks – victor Jul 07 '13 at 12:37
  • interesting. did you run git with sudo? can you post the full output? – CuriousMind Jul 07 '13 at 13:18
  • posted full output in main post... i even tried git with sudo but not working ... Thanks – victor Jul 07 '13 at 13:45
  • 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? – CuriousMind Jul 07 '13 at 13:48
  • Hi, I got solution from this, Thanks for your help...After adding SSH identity it is working.. http://ripan27.wordpress.com/2010/04/01/ssh-gitgithub-com-agent-admitted-failure-to-sign-using-the-key-permission-denied-publickey/ Thanks – victor Jul 07 '13 at 14:35
0

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

Try it

Community
  • 1
  • 1
QuestionEverything
  • 4,809
  • 7
  • 42
  • 61
  • 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 – victor Jul 07 '13 at 12:22