‘git push heroku master’ error – ‘your account does not have access’

Home / Blog / ‘git push heroku master’ error – ‘your account does not have access’

CAUSE

I have two git repositories, each supposed to deploy to a different heroku account.

ERROR

When trying to run git push heroku master it triggered this error:

 !  Your account email@whatever.com does not have access to heroku_app_name.
 !  
 !  SSH Key Fingerprint: 30:02:49:32...

fatal: Could not read from remote repository.

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

SOLUTION

I had to tell heroku to use a specific, separate SSH key for each one (apparently, not just the first available one, which seems to be the default behavior). The exact method that worked for me was following the steps here and then here.

The details:

1. Create a new rsa key: Specify any email you want and choose a name that will be easy for you to remember and associate with the specific heroku app. Or you could name it something like /id_rsa_herokualt.

$ ssh-keygen -t rsa -C "youremail[at]domain.com" -f  ~/.ssh/id_rsa_myherokuapp

2. Add to your machine: Make sure to type in the exact file name as you just specified it in the last step.

$ ssh-add ~/.ssh/id_rsa_myherokuapp

3. Add to Heroku: This assumes you have already logged into heroku using heroku login.

$ heroku keys:add ~/.ssh/id_rsa_myherokuapp.pub

4. Add an alternate host for heroku.com to your ~/.ssh/config. Locate this file by going to Finder and pressing command + shift + g and typing in ~/.ssh/. Open the Config file in a text editor, add the following text, and then save it:

Host heroku-alt
HostName heroku.com
IdentityFile ~/.ssh/id_rsa_myherokuapp

5. Update the .git/config in your project to use the host alias. Locate this file by going to Finder and pressing command + shift + g and typing in ~/path/to/your/repository/.git. Open the Config file in a text editor, add the following text, and then save it:

[remote "heroku"]
  url = git@heroku-alt:myherokuapp.git
  fetch = +refs/heads/*:refs/remotes/heroku/*

Explanation

By choosing between heroku and heroku-alt in the remote of the .git/config files of specific projects you can manage which projects use which credentials.

Recent Posts

Comments

  • Arul
    Reply

    Thnx brownborg,my problem is finally fixed.

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.