News for hackers. Stuff that matters.
Re:Conditional Git Configuration by de6u99er on Wednesday January 10, 2024 @06:05PM (#38944800)
You can also configure multiple ssh keys through Github subdomains in your ssh conf file. While github ignores the subdomain your ssh-client will pick the corresponding ssh key bas d on the used subdomain in your repo url.
Re:Conditional Git Configuration by vifon on Wednesday January 10, 2024 @07:45PM (#38945822)
This works only under the assumption Github won't change the current DNS setup that happens to work this way. A trivial example would be adding a record for the specific subdomain one used directing it to some completely different IP address. Not something I'd be willing to bet on, especially considering the much cleaner solution from the original post.
Re:Conditional Git Configuration by krick on Wednesday January 10, 2024 @07:08PM (#38945483)
So subdomains can be arbitrary and you just manually add them when performing git clone? Will then git push/pull/etc automatically use the fake subdomain you like for this repository?
Re:Conditional Git Configuration by koolba on Wednesday January 10, 2024 @07:22PM (#38945599)
You can have anything you’d like in your ssh config and it will be treated as a server name for auth and auto completion.

So “work-github” can be a Host entry (with a HostName of github.com) and key A. While “play-github” would use key B.

Re:Conditional Git Configuration by krick on Wednesday January 10, 2024 @09:12PM (#38946563)
You are basically just repeating what he said, but it doesn't answer my question. After all I'm not ssh-ing to GitHub directly, I'd use git, which will use ssh as a transport, and I don't know if git will use the subdomains I provide the way I think it should (my primary concern being to prevent GitHub from displaying 2 public keys for a single account, so that 3rd party cannot tell that it's most probably the same person).

Of course, I can test it myself, but since somebody already does that I assumed I could just ask.

Re:Conditional Git Configuration by gertlex on Wednesday January 10, 2024 @10:34PM (#38947204)
I tested it myself, like `ssh [email protected]` and that didn't work.

That was my interpretation of the original comment. (reading it again, it seems like it was indeed saying what I typed below)

It seems like the reply was saying instead you can do in your .ssh/config file

   Host work.github.com
   HostName github.com
   Host me.github.com
   HostName github.com
(or just leave out the .github.com in the Host part)

So `ssh [email protected]` now works...

And then key the github config off of that? But I didn't try that part. So I could be wrong there.

Re:Conditional Git Configuration by hashhar on Friday January 12, 2024 @02:04AM (#38964964)
Yes this is what they mean. I've use this setup in the past when for example I wanted to use different SSH keys for bitbucket, gitlab and github for example.

It works even for same hostname like I did here - https://github.com/hashhar/dotfiles-tmp/blob/master/ssh/.ssh...

Re:Conditional Git Configuration by brazzledazzle on Wednesday January 10, 2024 @08:44PM (#38946338)
Do you mean a host alias in your SSH config (e.g. `Host your-github-alias` or configuring a subdomain in for the hostname in the config (e.g. `Hostname something-fake.github.com`)?