git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Use different ssh keys for different github repos (per-url sshCommand)
@ 2018-07-19 12:24 Basin Ilya
  2018-07-19 12:50 ` Ævar Arnfjörð Bjarmason
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Basin Ilya @ 2018-07-19 12:24 UTC (permalink / raw)
  To: git

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@github.com:other/publicrepo.git
       ~/.ssh/id_rsa
    git@github.com: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@github.com: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@github.com git-upload-pack '/theorganization/privaterepo.git'

Is this the only option?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-07-19 19:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-19 12:24 Use different ssh keys for different github repos (per-url sshCommand) Basin Ilya
2018-07-19 12:50 ` Ævar Arnfjörð Bjarmason
2018-07-19 16:47   ` Jeff King
2018-07-19 13:22 ` Sitaram Chamarty
2018-07-19 13:27   ` Sitaram Chamarty
2018-07-19 16:42 ` Jeff King
2018-07-19 19:01   ` Basin Ilya

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).