Reputation: 981
I'm having trouble when working with multiple Heroku accounts on my computer.
The thing is that it's worked great before by switching accounts with the heroku gem. But now (even though I've generated new SSH keys) it wont work.
When I do a git push heroku master
it just says:
[email protected] not authorized to access my_app_name
Does anyone have any advice on how I could solve this?
Upvotes: 95
Views: 35762
Reputation: 4736
Install Heroku-accounts plugin and configure it!!
heroku plugins:install heroku-accounts
To add accounts:
$ heroku accounts:add personal
Enter your Heroku credentials.
Email: [email protected]
Password: ******
To list accounts:
$ heroku accounts
* personal
work
To switch to a different account:
heroku accounts:set personal
To find current account:
$ heroku accounts:current
personal
To remove an account:
$ heroku accounts:remove personal
Account removed: personal
set to your working heroku account and push the changes.
Upvotes: 4
Reputation: 305
I used nano .git/config then replaced value of url of remote "heroku" with heroku.com > apps > settings > Reveal config vars > Heroku Git URL
Upvotes: 1
Reputation: 4964
You need to ensure that you are using the correct ssh key.
The way to do this (and the way the heroku accounts plugin prompts you) is to add a section to your ssh config file in ~/.ssh/config. For instance, for my work heroku account I have this in my ssh config:
Host heroku.work
HostName heroku.com
IdentityFile ~/.ssh/id_heroku_work_rsa
IdentitiesOnly yes
Now, and this is crucial, you need to make sure that your git remote is set up to use that same named host. In this case it is heroku.work. Normally it would be heroku.com if you were using heroku with only a single account.
So you'll need to edit the git remote (you can do this in the .git/config
file of your repo on your machine). Change the file to look like:
[remote "heroku"]
url = [email protected]:<appname>.git
Note the heroku.work, not heroku.com, and replace <appname> with the name of your app (aka your repo name) on heroku.
Upvotes: 164
Reputation: 660
The Heroku plugin https://github.com/ddollar/heroku-accounts has been deprecated. Heroku now maintains its own at https://github.com/heroku/heroku-accounts. Unfortunately it doesn't seem to store project-by-project which account it should be using so you need to run
$ heroku accounts:set account_name
each time you want to use the Heroku command-line tool.
Quick solution for people with access to the bash shell: make a local bin directory (it's already there in Rails applications) and create bin/heroku there. Contents:
#!/bin/bash
/usr/bin/heroku accounts:set account_name
/usr/bin/heroku $*
(replace "project_name" as appropriate) Then run
$ chmod +x bin/heroku
You can then run
$ bin/heroku run console
and it will automatically use the right Heroku account for you. Better still is to add ./bin to your path so you're back to just running:
$ heroku run console
Upvotes: 7
Reputation: 37103
This has been bugging me for a while, and I never found a solution that I liked. Finally found one.
(OS X specific answer.)
You can just create new users. Go to System Preferences -> Users & Groups -> Add user or group button. You can create a few users for different heroku accounts, I just named mine user1, user2, etc.
Then go to System Preferences -> Sharing -> Remote Login -> Allow access for: All Users
At this point, you can go to a terminal and do the following:
$ ssh user1@localhost
Then you can do things like this:
$ heroku login
$ heroku keys:add
Upvotes: 1
Reputation: 171
create new public/private key for new email as follows
1) ssh-keygen -t rsa -C "[email protected]"
2) provide new file name in which to save the key (/home/.ssh/seckey)
3) Then add your new key to the ssh-agent:- ssh-add ~/.ssh/seckey
4) Then add your new key to heroku :- heroku keys:add ~/.ssh/seckey
5) add SSH Config File as ~/.ssh/config and content as follows
Host heroku.com Hostname heroku.com Port 22 IdentitiesOnly yes IdentityFile ~/.ssh/seckey User [email protected]
Host heroku.com Hostname heroku.com Port 22 IdentitiesOnly yes IdentityFile ~/.ssh/id_rsa User [email protected]
6) clone the code using either
a) git clone [email protected]:your-application.git b) heroku git:clone -a your-application
Upvotes: 0
Reputation: 468
To get this to work for me with both Git and the Heroku console, I had to add create the ssh config as instructed by bantic, but I also had to create two remotes to my .git config:
[remote "origin"]
url = [email protected]:pacific-rock-4904.git
fetch = +refs/heads/*:refs/remotes/heroku/*
[remote "heroku"]
url = [email protected]:pacific-rock-4904.git
fetch = +refs/heads/*:refs/remotes/heroku/*
Upvotes: 1
Reputation: 1608
i am using win7
1) create another user account in win7 and log into it
2) open git bash and log into your new heroku account
3) create and upload new RSA key (instruction here : https://devcenter.heroku.com/articles/keys)
4) then do what ever you want (create new app, push file to it .....)
5) every time you need to work with your original heroku account just log into your original win user account and work with heroku
Upvotes: 0
Reputation: 1082
I started using the heroku-accounts plugin but then realized my buddy could just make me a collaborator on his heroku account and that was all that was needed.
Upvotes: 2
Reputation: 19247
I'd add a couple of things re the heroku-accounts plugin... this example assumes your pre-existing heroku account will be heroku.work and you are adding a new account heroku.personal.
It also describes how to move an app from one to the other, for example, if you have hit your 25-app max and are creating a new account and want to move some of your side projects and experimental apps out of your main account.
heroku accounts:set personal
) until after you transfer the app using the heroku sharing
commmand as described https://devcenter.heroku.com/articles/transferring-appsSo the steps you probably need are:
heroku accounts:add work --auto
to create a new heroku.work account to replace your old default account (so use the same credentials you've been using all along). You ALSO need to upload your new key to heroku: heroku keys:add ~/.ssh/identity.heroku.work.pub
heroku accounts:add personal --auto
to create a new heroku.personal account (eg use your new credentials for your new heroku account). You ALSO need to upload your new key to heroku: heroku keys:add ~/.ssh/identity.heroku.personal.pub
heroku accounts:set work
(all that does it setup git to use your heroku.work, which is (unin this example) the same heroku account you've been using all along, only now it's called heroku.work. heroku sharing:add <new owner email>
(b) in your local directory, switch the app to heroku.personal using heroku accounts:set personal
(c) transfer** the app from the old account to the new account using heroku sharing:transfer <new owner email>
then (d) remove the old email address collaborator (if you want to) using heroku sharing:remove <old owner email>
** Note the heroku link I provided says there are special requirements to move an app with any paid resources. Generally, remove the paid resoures, then add them back later, or have support do it.
Upvotes: 6
Reputation: 1148
You've got to be accepted as a collaborator on the project you don't own.
It works like this (using git) :
And that should be all folks ; you just have to push on the other remote when deploying on the other app.
Upvotes: 8
Reputation: 396
I solved this by using the heroku-accounts plugin
see here for instructions
http://martyhaught.com/articles/2010/12/14/managing-multiple-heroku-accounts/
Upvotes: 36
Reputation: 623
I have the exact same problem.
This is not the answer, but a temp solution is to add your "standard" heroku email as a collaborator to the app you can't access.
Upvotes: 0
Reputation: 11342
Edit your config for that project, setting the correct email. From the root of that repository, git config user.email <heroku email>
Upvotes: -1