From: Basin Ilya <basinilya@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: Use different ssh keys for different github repos (per-url sshCommand)
Date: Thu, 19 Jul 2018 22:01:29 +0300 [thread overview]
Message-ID: <966f577f-c4ca-46a4-d55d-817e84780324@gmail.com> (raw)
In-Reply-To: <20180719164251.GA4868@sigill.intra.peff.net>
Wow, thanks.
For me it was enough to configure just one rewrite, because my public github account is associated with my default key. Note that I added the missing slash and the username:
git config --global \
url.git@gh-org:theorganization/.insteadOf \
git@github.com:theorganization/
19.07.2018 19:42, Jeff King пишет:
> On Thu, Jul 19, 2018 at 03:24:54PM +0300, Basin Ilya wrote:
>
>> 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 think you can hack around this using Git's URL rewriting.
>
> For example, try this:
>
> git config --global \
> url.gh-other:other/.insteadOf \
> git@github.com:other/
>
> git config --global \
> url.gh-org:theorganization.insteadOf \
> git@github.com:theorganization/
>
> And then:
>
> git clone git@github.com:other/publicrepo.git
>
> will hit gh-other, which you can configure using an ssh host alias.
>
> -Peff
>
prev parent reply other threads:[~2018-07-19 19:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=966f577f-c4ca-46a4-d55d-817e84780324@gmail.com \
--to=basinilya@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).