Pompey
Pompey

Reputation: 606

managing multiple ssh keys on heroku

so I have a couple of ssh keys that are used for other accounts that I have. I now need to be able to clone a heroku repository on my computer. I created a new ssh key and used heroku keys:add to add it to my heroku account. However when I try and clone the repository I get this error: Your key with fingerprint: .... is not authorized to access rural-visions. fatal: the remote end hung up unexpectedly

I've heard that I need to create a config file in the .ssh folder, but I don't know what to put into there.

Any help would be really appreciated!

Upvotes: 4

Views: 3970

Answers (1)

CodeMangler
CodeMangler

Reputation: 1709

I sometimes have to work with a bunch of heroku accounts, and have run into this. Here's what I usually do:

  • Clear identities

    $ ssh-add -D
    
  • ssh-add the key that I need for the current account

    $ ssh-add ~/.ssh/an_account_key
    
  • Now I can push to my heroku app

    $ git push heroku-remote master
    

Of course, this assumes that the key has been added to the heroku account already. You can do that with:

$ heroku keys:add

The correct way to solve this is with an SSH configuration in ~/.ssh/config, but that's a bit much for me since I only switch accounts occasionally.

Googling about the SSH configuration file should turn up plenty of results, but here's some that might help:

Upvotes: 15

Related Questions