Can I use different Heroku credentials on different projects?

  • Question
  • Updated 5 months ago
  • Answered
@heroku is it possible to have per-project credentials? If I wanted to push with different credentials than listed in ~/.heroku/credentials
Photo of wuputah

wuputah

  • 11 Posts
  • 4 Likes

Posted 5 years ago

  • 2
Photo of David Dollar

David Dollar, Official Rep

  • 17 Posts
  • 3 Likes
Official Response
One other thing to be aware of is how to make SSH deal with multiple SSH keys for git pushes.

I create two files:

~/.heroku/personal
~/.heroku/work

I then use this bash function to switch

hcs()
{
ln -sf ~/.heroku/$1 ~/.heroku/credentials
}

My ~/.ssh/config has this in it:

Host work.heroku.com
User git
Hostname heroku.com
IdentityFile ~/.ssh/identity.heroku
IdentitiesOnly yes

So when I create remotes like

git@work.heroku.com:appname.git

it is guaranteed to use a specific key for authentication.