26

git clone [email protected]:myapp.git

Results in a "myoldemailaddress not authorized to access myapp"

myoldemailaddress was an email address I was using on an old heroku account, but it seems to be stuck using it, I can use my new one.

I've removed the .heroku directory, and regenerated it, it has the correct user name and password, I can see my apps listed I've uploaded my key (I've regenerated my several times now) ssh-keygen -t rsa -C mynewaddress

I uninstalled and reinstalled heroku on a different user in the same machine it works just fine.

Something about my account has my old address, but I can't figure out where.

2
  • Have you tried removing .ssh or .git? Take backups before trying.
    – ponzao
    Jun 10, 2010 at 9:22
  • What does your ~/.ssh/config look like? Feb 17, 2011 at 20:36

10 Answers 10

41

In case you still need an answer to this, the problem is that you probably have an old ssh key loaded in your ssh-agent.

To check your currently loaded keys, use the following command:

ssh-add -L

First remove that key from the agent with (remember sudo):

sudo ssh-add -d

Then, add the new key (the one with yournewemailaddress) with

ssh-add /path/to/your/private/key/file

This should fix the problem.

3
  • 1
    I thought this didn't apply to me because the correct key was loaded, but removing it and re-loading it fixed it. Aug 12, 2011 at 19:26
  • 2
    As a side note to this, if you want to remove ALL your keys, do ssh-add -D (capitalized D).
    – jakecard
    Oct 9, 2011 at 21:22
  • Another note: For the ssh-add -d invocation, I needed to run ssh-add -d <filename> where filename was something like ~/.ssh/my_other_key. Feb 5, 2013 at 3:10
5

I solved the same problem with the following steps:

  1. deleted the application on heroku

  2. generated new keys with

ssh-keygen -t rsa -C myNewEmail

  1. uploaded new keys with

heroku keys:add

  1. recreated and pushed the application

some steps may be optional (like deleting the application) but this worked!

E/

0
4
+50

I was having this same problem - and rebooting my computer fixed it.

3

Do you have your myoldemailaddress still listed as your user in your global gitconfig file?

[user]
name = David
email = myoldemailaddress@...

I'm not sure if heroku uses this at all, but that's the next place I'd look.

0
1

You can add "myoldemailaddress" as a collaborator in your heroku app

1

In my case, the problem was I had two users at heroku, pupeno@home and pupeno@work. My personal keys where injected in both users so when I was working on a personal project I was getting:

$ git push heroku master

 !  pupeno@work not authorized to access home-project

fatal: The remote end hung up unexpectedly

Removing and re-adding the key, like Juan explained, worked, but only until my computer was rebooted. Removing the key from the work user finally fixed it. I did it with

heroku keys:remove pupeno@home

in my work machine. Not sure how to do it for an old user. I suppose removing ~/.heroku/credentials, then running a heroku command and logging in with the old user.

0

Does your project root have a .git folder? If it does, check the config file in there. The project-level config might have your old email address set, which is overriding your global setting.

0

Look inside .git/config which overrides your global ~/.gitconfig.

0

You could also try and create a new branch from the origin, and then reapply all your changes to that new branch. Somehow, this worked for me. Maybe Git stores the user email somewhere in your local repo? My problem was that even though I had changed my email address everywhere, and updated my keys, it would still not change to the new email address.

0

This plugin https://github.com/heroku/heroku-accounts worked great for me. It was stuck on my work Heroku account and I used this to add my personal account and switch over to it. Very simple to use and offers an easy way to switch between accounts.

Using the terminal, to install: heroku plugins:install heroku-accounts

Add an account: heroku accounts:add personal

You will then be prompted for your heroku email and password.

To switch to that account: heroku accounts:set personal

To list accounts: heroku accounts

To find current account: heroku accounts:current

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.