28

I am having trouble pushing code to Heroku. I have an account but I've forgotten the password. I created a new account and tried to push with it but now it shows me this error:

Your account [email protected] does not have access to
! SSH Key Fingerprint: 

How can I log in with the new account? I'd like to remove this error message with a fresh account. I have uploaded my latest ssh key to heroku. I have tried everything to push code on heroku (basic setup), but I can't get past this error.


Any application in your account has two ssh key and you should remove one which is not in your "~/.ssh/" folder or follow these steps.

Here's the solution:

  1. Go to www.heroku.com and login with the account that raises the error.

  2. Go to the applications settings. (e.g. for an application named "rails-demo", go to rails-demo settings and check whether there are two ssh keys)

  3. Remove the key which is no longer in your system

  4. Or you can remove them both and then generate new one with these commands.

    -> ssh-keygen -t rsa

    -> heroku keys:add

  5. Upload the new one and then in your console type

    -> heroku log-in

  6. Log in with your account and then push it to you app.

  7. It's solved now.

0

6 Answers 6

26

You need to:

Make sure your ~/.ssh/config file has an 'myNewAccount' entry

Host heroku.myNewAccount
  HostName heroku.com
  IdentityFile ~/.ssh/id_heroku_myNewAccount_rsa
  IdentitiesOnly yes

And then change the remote 'origin' url:

git remote set-url origin [email protected]:<appname>.git

Or, as Ian Vaughan comments below

origin is normally heroku when using the 'heroku-toolbelt':

git remote set-url heroku [email protected]:<appname>.git

That last step will make sure the git push will use your new account, and not the old one.

See more at "Multiple heroku accounts".


If you add "User git" in your config file, you can remove the credential user name 'git':

Host heroku.myNewAccount
  User git
  HostName heroku.com
  IdentityFile ~/.ssh/id_heroku_myNewAccount_rsa
  IdentitiesOnly yes

That means you can use:

git remote set-url origin heroku.myNewAccount:<appname>.git
# or
git remote set-url heroku heroku.myNewAccount:<appname>.git
6
  • but i want to remove all the credentials. how to do that? still m getting the error.
    – SSR
    Commented Dec 17, 2013 at 14:30
  • @SSR I have edited the answer: you can remove the 'git@' part of the url, but some kind of credential will have to be used when accessing to your remote url.
    – VonC
    Commented Dec 17, 2013 at 14:34
  • 1
    In my case, was necessary only the last step. When I create the account it got the appname wrong. Change it only the "origin" for "heroku" and the appname to my right appname. Commented Mar 28, 2014 at 1:54
  • As @CassioS.Cabral states, origin is normally heroku when using the heroku-toolbelt, not sure if the answer needs updating as origin is the norm, and people know what that means?! Commented May 23, 2014 at 20:25
  • @VonC I like the or, I didnt think of that. Commented May 23, 2014 at 20:33
23

This worked for me:

$ heroku auth:logout

Then

$ heroku auth:login
2
  • +1 to share your solution. Yes this will destroy your current session so you can continue with another session after.
    – SSR
    Commented Apr 4, 2015 at 4:52
  • 1
    Knew it would be something simple.
    – rick6
    Commented Jun 24, 2020 at 21:20
2

I hope this work for you. By using this gem you can manage multiple account https://github.com/ddollar/heroku-accounts

1
  • 1
    Ya you can do it with this but you should remove extra ssh keys from your heroku account app. see mine solution and @VonC's answer.
    – SSR
    Commented Dec 20, 2013 at 7:42
1

Remove ssh key from your "homedir/.ssh" and check whether from that ssh key would not be available there.

I solved using your question after update.

1

If you have multiple accounts then login with the new or required one

$ heroku login
Enter your Heroku credentials.
Email: [email protected]
Password: 

$ heroku keys:add

generate keys if you have old one already in use for another heroku account.

1
  • Then what about old one? If I need to use old account then? This is just for heroku account authentication. This won't work.
    – SSR
    Commented Nov 19, 2014 at 9:41
0

I had this same issue when deploying a Rails application to Heroku.

After logging in to the Heroku CLI using the command:

heroku login

and also creating the new app using the command:

heroku create

when I run the command git push heroku main, I get the error below:

remote: !       Your account [email protected] does not have access to stark-temple-39676.
fatal: unable to access 'https://git.heroku.com/stark-temple-39676.git/': The requested URL returned error: 403

I tried several solutions but none worked for me.

Here's how I fixed it:

First I ran the command git remote -v to see the list of remote, and I got this output:

heroku  https://git.heroku.com/stark-temple-39676.git (fetch)
heroku  https://git.heroku.com/stark-temple-39676.git (push)

The issue was that the name of the heroku git repo stark-temple-39676 was different from the name of the app gentle-lowlands-46404. Apparently, the heroku repo name stark-temple-39676 was for a previous app that I had earlier deployed to Heroku using another Heroku account.

All I had to do was to remove the heroku repo name:

git remote rm heroku

And then delete the app;

heroku apps:destroy --app=gentle-lowlands-46404

And then recreate the app:

heroku create

This time when I pushed the app using the command:

git push heroku main

it worked perfectly.

Note:

  1. You can just modify the repo name for the old app to say heroku-old if you still need it and then recreate the new app.
  2. You can also add the git repo URL for the new app from your Heroku account dashboard instead of deleting it and recreating it.

That's all.

I hope this helps

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