Multiple Heroku Accounts on one machine

To have multiple accounts on Heroku is no fun. Specially not if you are a developer and you have to push multiple apps into multiple heroku accounts.

The problem is that the heroku toolbelt authentification is based on ssh certificates. If you create your very first heroku app on your machine, heroku will take your default ssl certificate to authenticate you. Every fingerprint can be only used for one account. It is not possible to use a specific certificate / fingerprint in multiple heroku accounts.

The solution is to have a certificate / fingerprint for every heroku account.

If you want to switch the heroku account you can do it like this:

> heroku logout
> heroku login

The heroku toolbelt will ask you for email and password. After the login process you should check your keys:

> heroku keys

Now you should see the key, which is related to the heroku account, you are logged in right now. if there is no key, you can create a new one with this command here:

ssh-keygen -t rsa -C "<YOUR_EMAIL_ADDRESS>" -f  ~/.ssh/id_rsa_heroku_second_account

Now you can add your new created key with this command:

> heroku keys:add

Now you will see a listing of all your keys. Just select the one you created above.

Now you have to add the key to your key chain:

> ssh-add ~/.ssh/id_rsa_heroku_second_account

With this command here you can see all keys in your key chain:

> ssh-add -l

If you see here multiple keys then you still could have problems by pushing code to the heroku Accout. If you get this Error Message by pushing to heroku:

!  Your key with fingerprint XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX is not authorized to access <YOUR_PROJECT>.

Then the problem is that your ssh client is sending the wrong fingerprint. You can resolve this by removing the first (default) entry with this command:

> ssh-add -r <PATH_TO_YOUR_DEFAULT_CERTIFICAT>

After that the new created certificat should be the only one you see if you type in:

> ssh-add -l

Now you should be able to execute:

> git push heroku master

without problems. At least that worked for me.

 

One thought on “Multiple Heroku Accounts on one machine

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s