Skip to content

Instantly share code, notes, and snippets.

@esteedqueen
Last active May 16, 2017 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esteedqueen/caa123e0c004495951b3d602764df8fd to your computer and use it in GitHub Desktop.
Save esteedqueen/caa123e0c004495951b3d602764df8fd to your computer and use it in GitHub Desktop.
Managing keys for pushing to multiple heroku accounts

I had a challenge with pushing to another heroku account from my command line...

These are the steps I took to fix the error (redacted) below:

 !  Your account xxx@gmail.com does not have access to xx-heroku-app.
 !
 !  SSH Key Fingerprint: xx:xx:xx...

fatal: Could not read from remote repository.

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

Create a new ssh key doc, you can customize the pub filename for the different keys.

Add new key to the machine: ssh-add ~/.ssh/id_rsa_myherokuapp

Install heroku accounts setup multiple accounts and login

Modify ~/.ssh/config and add different alternate hosts for heroku.com to your ~/.ssh/config for each heroku accounts e.g.

Host heroku.myherokuapp
  HostName heroku.com
  IdentityFile ~/.ssh/id_rsa_myherokuapp
  IdentitiesOnly yes

Login to the right heroku account and add the newly created key using heroku keys:add

To view all the heroku accounts you have setup, run heroku accounts

To find out the current heroku account you're logged into, run heroku accounts:current

To switch to the desired heroku accounts, run heroku accounts:set name_of_account

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment