Heroku
Managing Multiple Heroku Accounts

© Heroku
I’ve been using Heroku for some time now. Well, ever since the Heroku Garden days — which was over a year ago. Seems longer. Anyway, I’ve got a handful of apps on Heroku. Some prototypes and some in production. I also have multiple accounts in play. The only problem is that this isn’t the easiest thing in the world to manage. In case you travel down this path, here are some tips.
Requirements
The following assumes you are on the MacOS, already own multiple Heroku accounts, have installed the Heroku gem, and have deployed a Ruby on Rails application to Heroku before. Otherwise, read the Quickstart docs and you’ll be up and running in no time.
Credentials
Let’s start with your credentials file (i.e. ~/.heroku/credentials). This file is usually created for you by the Heroku gem when you setup your first account. It is a text file with your account login (i.e. email address) on the first line and your password on the second line. To setup multiple accounts, I’d suggest the following:
- ~/.heroku/credentials - Your current account that is in play.
- ~/.heroku/account_1.credentials - Your first account.
- ~/.heroku/account_2.credentials - Your second account.
When you need to switch accounts simply copy the contents of the account you are switching to over the existing credentials file (example: account_2.credentials now becomes credentials). I wrote a simple Ruby gem called Heroku Plus that easily automates the switching of accounts for you. Now, from the command line, you can simply type the following to switch between accounts:
herokup -a -s <account>
Security Keys
Right, so we have the credentials files out of the way but there is one last step. You need to associate your public key with each account. Here is my suggestion:
- Change directory to
~/.ssh - Create your private and public keys for each account by running the following command:
ssh-keygen -t rsa -C "<email>" -f ~/.ssh/<account>.identity - Type
heros <account>to switch account and add the new keys for each:heroku keys:add [path to keyfile].pub
For each Heroku account beyond your first, you’ll need to make use of the SSH config file (i.e. ~/.ssh/config) as follows (thanks to the Heroku support team on this one):
- Host official.heroku.com
- HostName heroku.com
- User git
- IdentityFile
~/.ssh/<account>.identity - IdentitiesOnly yes
Also, for each account beyond the first, you’ll need to switch to each app directory and type the following command: git remote add heroku git@official.heroku.com:<your app>.git. This will allow you to push and deploy your changes back to the Heroku servers and finalizes your setup.
Workflow
From this point forward, you can switch between accounts as follows:
- Change directory to the app you want to work on.
- Type:
hp -a -s <account>. - Make changes to your code.
- Type: git commit -a -m “Your comments.”
- Type: git push heroku.
- Have a beer.
Search
Categories
- Adventures
(145)
- Announcements
(39)
- Business
(20)
- Electronics
(22)
- Employment
(1)
- Epicurean
(10)
- Games
(2)
- Literature
(1)
- Mechanical
(4)
- Meetups
(15)
- Movies
(2)
- Music
(26)
- Photography
(1)
- Services
(27)
- Software
(134)