Skip to content

Instantly share code, notes, and snippets.

@Hefeweizen
Created December 18, 2020 23:15
Show Gist options
  • Save Hefeweizen/cb4954a9b29fdf9842e3e6188efcecee to your computer and use it in GitHub Desktop.
Save Hefeweizen/cb4954a9b29fdf9842e3e6188efcecee to your computer and use it in GitHub Desktop.
My company uses Github for repo storage. I generally check out work repos to ~/Workspace. Other stuff, like my ~/dotfiles are going to other directories. So, here, I use my company wide id_ed25519 key for ssh access to github if I'm in '*/Workspace'. Otherwise, I use credentials scoped to my personal Github account.
Host *
PermitLocalCommand yes
StrictHostKeyChecking ask
Host github.com
HostName github.com
User git
IdentitiesOnly yes
Match Host github.com exec "pwd | grep '/Workspace' > /dev/null"
IdentityFile ~/.ssh/id_ed25519
Match Host github.com !exec "pwd | grep '/Workspace' > /dev/null"
IdentityFile ~/.ssh/gh_hefeweizen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment