Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

managing multiple ssh keys on heroku

Tags:

ssh

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!

like image 366
Pompey Avatar asked Dec 06 '22 10:12

Pompey


1 Answers

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:

  • SSH config - same host but different keys and usernames
  • Specify an SSH key for git push for a given domain
  • Simplify Your Life With an SSH Config File
like image 190
CodeMangler Avatar answered Jan 11 '23 09:01

CodeMangler