2

I have two ssh keys to work with github - my own and one from organisation where I'm working. My key was generated automatically by github gui client and the other one was generated by portablegit. My .ssh folder looks like:

github_rsa            <--- my key
github_rsa.pub
id_rsa                <--- org key
id_rsa.pub

When I use portablegit it takes the key with name 'id_rsa' but sometimes I need to use my key too. How can I setup default key?

rand0m86
  • 3,172
  • 4
  • 26
  • 29

1 Answers1

2

You can by adding to your HOME/.ssh a config file:

Host wpengine 
user git
hostname git.wpengine.com
IdentityFile ~/.ssh/myPrivateKey

You can add as many 'Host' entry as you want, each one with a different IdentityFile

See for instance "Multiple SSH Keys settings for different github account"

#activehacker account
Host github.com-activehacker
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_activehacker

#jexchan account
Host github.com-jexchan
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_jexchan

You can then use the scp syntax for cloning your repo:

git clone github.com-activehacker:activehacker/gfs.git gfs_jexchan

(instead of ssh://git@github.com/activehacker/gfs.git, which wouldn't be able to reference a specific private key and would always fall back to id_rsa.)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250