Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push heroku master permission denied

I am following the ruby.railstutorial. I run the command "git push heroku master" and it spits out this error.

Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

I am inside my rails app "/Users/lexi87/rails_projects/first_app". Any solutions?

like image 578
Cornelius Wilson Avatar asked Jan 15 '13 16:01

Cornelius Wilson


People also ask

How does git push heroku master work?

To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.

What is heroku git URL?

In your heroku account, go to your app -> Settings. Under App Information, you'll find the heroku git url. answered Sep 7, 2020 at 14:16. sidekickbottom.


2 Answers

The best way to avoid such errors is to use one public/private key pair and not an extra key for heroku. This way you (or your system) can't choose a wrong key to login in heroku.

If you get this error, you have done something wrong. Check this site: https://devcenter.heroku.com/articles/keys

If you geht this error, the best way is to remove unnecessary keys and use only one.

If you need more than one key pair on your system, you can set one key for heroku. This is done through the following command:

heroku keys:add 
like image 168
Fa11enAngel Avatar answered Sep 21 '22 10:09

Fa11enAngel


Some help for Windows 7 users with Github Windows client installed:

Even though heroku toolbelt reports it found my git_hub public key and uploaded it, 'git push heroku master' failed. After taking the steps below, it works fine.

  1. Create .ssh folder under your User folder if one does not exist. If it does, delete all files in it (this assumes you are OK with starting from scratch with ssh keys).

  2. In Windows Explorer, right click the .ssh folder, and choose Git bash from the context menu. This is installed along with the Github Windows client software.

  3. In the bash window enter ssh-keygen -t rsa -C "[email protected]" When prompted enter a passphrase (don't lose this).

  4. Close the bash shell window.

  5. From a cmd prompt in your project's root, enter heroku keys:add. This will find and upload the key you just created from your /.ssh file to Heroku.

Now you can enter git push heroku master to push you app up to Heroku. Note: you will need to add your newly generated ssh public key to your Github account when done.

like image 35
mjulmer Avatar answered Sep 23 '22 10:09

mjulmer