Blog An exploration of the art and
craft of software development

Managing Multiple Heroku Accounts

Posted by Marty Haught on Tuesday, December 14, 2010

I recently ran into an issue where my personal Heroku account and the owner account of a Heroku app that I was maintaining were different. For those that don’t know, your account is tied to an ssh key which allows you to run privileged commands via terminal. Though you can get most of these commands being a collaborator on a project, you cannot add addons or manage resources. For that you must be the owner. The issue in this situation was the ‘owner’ had no technical skills and was not going to be running commands. Even if he could run these commands, he was paying me to manage the whole process so I needed to act on his behalf. As you can imagine, I don’t want my personal account to ‘own’ his application. So how do you deal with this?

Let’s understand a bit more about how your account is associated. When you install the Heroku gem and run your first command it will ask you to enter your email and password and set your default ssh key before the command is issued. It will store this data into a .heroku/credentials file in your home dir. The problem is you can’t add another email account. One option is to make multiple credential files for each account you want to impersonate. You would then need to change out the file based on what user you want to impersonate. Not ideal.

Luckily someone else has had this problem and wrote up a Heroku add-on. @ddollar created heroku-accounts to manage this for us. The rest of this post is just an explanation of what I ended up doing and his readme is more than sufficient to guide you. What I find curious is Heroku has no official doc on how to tackle this problem though I suspect that will change soon (especially since a couple of my friends work there and will likely add it after reading this).

Install the add-on

heroku plugins:install git://

Next set up your personal account (the one you use for all your side projects, hacking, etc). It will ask you for your email and password.

heroku accounts:add personal

This way of adding an account will require you to tie your ssh key to the account manually. The command gives you an example to put into your ~/.ssh/config file, such as:

Host heroku.personal
  IdentitiesOnly yes

Since you most likely want this account to be your Heroku default run this command:

heroku accounts:default personal

Next up, it’s time to make a new account for your client. In this case because we’re starting fresh you can use the auto option which will generate an ssh key and modify your .ssh config.

heroku accounts:add <client> --auto

It’s going to ask you for an email and password like the first account add. In this case you use your client’s owner email and password. Once in place you can run Heroku commands as owner.

Now whenever you want to act on the behalf of the owner you just need to make sure you’re using the client account such as:

heroku accounts:set <client>

Need to see which accounts you have installed and which one is active? Just the standard accounts command does the trick.

heroku accounts

If you want to learn more about the commands this addon has, just ask help:

heroku accounts --help

I foresee that I will have to act as owner on several Heroku accounts in the near future. Having a way to sanely change accounts is going to be vital. I don’t think I’ll be the only person with this situation. Hope this helps!

blog comments powered by Disqus