On Tue, Apr 19, 2016 at 2:48 AM, Bennet Fauber <[email protected]> wrote:
> In mucking about trying to become a certified (not certifiable!) SWC
> instructor, I managed to mangle Github pretty badly.  But, something
> came of it that, if it isn't something you've done for just ages, you
> might find useful if you need to have two Github identities going at
> once and you like to use ssh keys.
>
> I have one identity, justbennet, and another carpenterbennet.  One I
> use for my real self, and one I use for workshops (say).  Under normal
> circumstances, if I check my git configuration for repos from each
> account, it would look something like one of these two entries:
>
> [email protected]:carpenterbennet/r-novice-gapminder.git
>
> [email protected]:justbennet/r-novice-gapminder.git
>
> My One True ssh key only works with one of those.  Maybe it's possible
> to munge that line with ssh options to specify the key to use; I
> didn't find one.  But, I did find that ~/.ssh/config can be used.  My
> first pass was to use
>
>
> Host github.com
>     IdentityFile /Users/bennet/.ssh/justbennet
>     # IdentityFile /Users/bennet/.ssh/carpenterbennet
>
>
> and I would modify the file when I needed the other key.  "But this
> solution did not satisfy me fully."[1]  Then something clicked, or
> snapped, and consulting the man page for ssh_config, I arrived at
> this.
>
> First, modify the ~/.ssh/config file so it has something like this in it
>
>
> Host carpenter-git
>     HostName github.com
>     IdentityFile /Users/bennet/.ssh/carpenterbennet
> Host just-git
>     HostName github.com
>     IdentityFile /Users/bennet/.ssh/justbennet
>
>
> Then, for your existing git configurations, change the hostname used
> from github.com to what appears as the Host in your ~/.ssh/config,
> thusly,
>
> remote.origin.url=git@carpenter-git:carpenterbennet/r-novice-gapminder.git
>
> remote.origin.url=git@just-git:justbennet/r-novice-gapminder.git
>
>
> If you want to clone a repo, make the same substitution on the clone
> command, i.e.,
>
> $ git clone [email protected]:carpenterbennet/r-novice-gapminder.git
>
> would become instead
>
> $ git@carpenter-git:carpenterbennet/r-novice-gapminder.git
>
> or
>
> $ git clone git@just-git:justbennet/r-novice-gapminder.git
>
> and it appears that git takes that hostname and stores it in its
> config, so if you clone that way you don't have to remember to modify
> git's configuration after.
>
> I did this from a Mac, but it should work equally well from Linux, BSD, et al.
>
> Sorry for the noise if that's old hat to everyone, but I thought it
> was a neat trick and maybe someone might find some use from it.

Actually, yeah! Thanks for this.  I have two GitHub accounts--one for
professional use, and one for personal use.  But I kind of gave up on
the personal one for exactly the issue you described.

This is a clever workaround which I haven't seen before.  I'll have to
give it a try.

Thanks,
Erik

_______________________________________________
Discuss mailing list
[email protected]
http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org

Reply via email to