0

I don´t know what I did , but for me its now a real mess. Im trying to push my rails app code to heroku with

git push heroku master

and this ERROR come up:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

ok, now i wil try to fix it making a new ssh key

sudo ssh-keygen -t rsa

I press enter three times and then my ssh key is created , OK.

But now when i say to heroku "Please add this new key" with:

     heroku keys:add

and then the terminal responds:

  Found the following SSH public keys:
  1) github_rsa.pub
  2) id_rsa.pub
  Which would you like to use with your Heroku account? 2
  Uploading SSH public key /Users/demarox/.ssh/id_rsa.pub... failed
   !    This key is already in use by another account. Each account must have a unique key.

I don´t understand what is happening, maybe computers are not my fort. And I am not using github_rsa.pub because it gave me more errors with heroku, and seems like id_rsa.pub is the ssh key that all people use, so I don´t want to mess with it. How do I Repair this?

EDIT: ok, maybe this will help. At this point I want to throw the computer out of the window.

 Demarox:saga_plast_app demarox$ 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.
 Demarox:saga_plast_app demarox$ sudo ssh-keygen -t rsa
 Generating public/private rsa key pair.
 Enter file in which to save the key (/var/root/.ssh/id_rsa): 
 /var/root/.ssh/id_rsa already exists.
 Overwrite (y/n)? y
 Enter passphrase (empty for no passphrase): 
 Enter same passphrase again: 
 Your identification has been saved in /var/root/.ssh/id_rsa.
 Your public key has been saved in /var/root/.ssh/id_rsa.pub.
 The key fingerprint is:
 f9:d0:45:80:4d:53:63:e5:36:38:60:80:ce:c8:1d:c9 root@Demarox.local
 The key's randomart image is:
 +--[ RSA 2048]----+
 |     . o.=*o=..  |
 |      E ...= +   |
 |   . = .    + +  |
 |    o +  o . o . |
 |        S .      |
 |         o       |
 |          .      |
 |                 |
 |                 |
 +-----------------+
 Demarox:saga_plast_app demarox$ heroku keys:add
 Found the following SSH public keys:
 1) github_rsa.pub
 2) id_rsa.pub
 Which would you like to use with your Heroku account? 2
 Uploading SSH public key /Users/demarox/.ssh/id_rsa.pub... failed
   !    This key is already in use by another account. Each account must have a unique key.
  Demarox:saga_plast_app demarox$ heroku  keys:clear
  Removing all SSH keys... done
  Demarox:saga_plast_app demarox$ heroku keys
  You have no keys.
 Demarox:saga_plast_app demarox$ heroku keys:add
 Found the following SSH public keys:
  1) github_rsa.pub
  2) id_rsa.pub
 Which would you like to use with your Heroku account? 2
 Uploading SSH public key /Users/demarox/.ssh/id_rsa.pub... failed
 !    This key is already in use by another account. Each account must have a unique key.
  • I think you need a primer on SSH. First, read this tutorial: http://support.suso.com/supki/SSH_Tutorial_for_Linux Then, check this stackoverflow question (I know you're not using multiple Heroku accounts, but if you're using multiple **any** account with SSH, this question is helpful): http://stackoverflow.com/questions/4663103/multiple-heroku-accounts – richsinn May 12 '14 at 19:00

2 Answers2

0

You shouldn't be using sudo when you are generating the key or doing a git push.

Using sudo causes it to execute the root user, and you can see from the messages it is printing that this is causing it to save the key to /var/root rather than to your home folder. Similarly this will cause git push to use the wrong ssh key.

Frederick Cheung
  • 83,189
  • 8
  • 152
  • 174
0

The sudo thing was not the problem. The deal was that i was loggin with a foreign account to upload to another different account. So the problem solved when i Logged again with the some account and then I restarted my SSH keys; worked. Thanks for the Support guys , I love You.