How to use specified key when working with github via portablegit?

后端 未结 1 1506
遥遥无期
遥遥无期 2020-12-11 10:20

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

相关标签:
1条回答
  • 2020-12-11 11:09

    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.)

    0 讨论(0)
提交回复
热议问题