Problem

I have two accounts on Heroku, one is for my personal use and a new one for my demo related apps. I have installed the heroku-toolbelt already on my computer and have logged in using my personal account. Now I wanted to logged in as demo account but the console returns me the following:

$ heroku login
Enter your Heroku credentials.
Email: [EMAIL HERE]
Password (typing will be hidden):
Found existing public key: C:/Documents and Settings/AJ/.ssh/id_rsa.pub
Uploading SSH public key C:/Documents and Settings/NCBaterina/.ssh/id_rsa.pub...failed!
This key is already in use by another account. Each account must have a unique key.

Analysis and Solution


It seems that Git already generated SSH keys and saved it locally. Now since this will be sent to Heroku and your old account already used this, this will be considered invalid by the server.

To resolve this, we need to generate a new SSH key that we can use.

  1. First, we need to check the existing SSH keys on our computer. Run the following command:

    $ cd ~/.ssh
    $ ls
    

    running ls will return you the following:

    config id_rsa id_rsa.pub known_hosts
    

  2. Back-up your existing SSH keys before removing it

    $ mkdir backup_keys
    $ mv id_rsa* backup_keys
    

    Just a quick explanation, the first line creates a back-up directory while the second line moves the keys to the said directory.

  3. Now try logging again on heroku by typing:

    $ heroku login
    

    This will prompt you again for you to create a new set of SSH keys.

    $ heroku login
    Enter your Heroku credentials.
    Email: [EMAIL HERE]
    Password (typing will be hidden):
    Could not find an existing public key.
    Would you like to generate one? [Yn] y
    Generating new SSH public key.
    Uploading SSH public key C:/Documents and Settings/NCBaterina/.ssh/id_rsa.pub... done
    Authentication successful.
    

Now, Git will generate a new SSH public key for your new account. This way you can now login using your alternate or new Heroku account without re-installing Heroku-toolbelt to the same machine. You can still access your old account using the same computer though.

2 comments :

  1. Shouldn't be cd ~/.ssh instead of cd ~/.sh ?

    ReplyDelete
  2. thanks for the comment.. yeah, it is ssh.

    It was a typo error on my part. Thanks for pointing out. :)

    ReplyDelete