Use different ssh keys for different github repos (per-url sshCommand)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi.

I have two github accounts, one is for my organization and I want git to automatically choose the correct ssh `IdentityFile` based on the clone URL:

    git@xxxxxxxxxx:other/publicrepo.git
       ~/.ssh/id_rsa
    git@xxxxxxxxxx:theorganization/privaterepo.git
       ~/.ssh/id_rsa.theorganization

Unfortunately, both URLs have same host name, therefore I can't configure this in the ssh client config. I could create a host alias there, but sometimes somebody else gives me the github URL and I want it to work out of the box.

I thought I could add a per-URL `core` section similar to `user` and `http`, but this section is ignored by git (2.18):

    [core "git@xxxxxxxxxx:theorganization"]
        sshCommand = /bin/false
        #sshCommand = ssh -i ~/.ssh/id_rsa.theorganization

I thought of writing a wrapper script to deduce the key from the arguments:

    git@xxxxxxxxxx git-upload-pack '/theorganization/privaterepo.git'

Is this the only option?



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux