Skip to content

Instantly share code, notes, and snippets.

@Daenyth
Last active April 21, 2022 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daenyth/f7bd4d7c9325f046322ad99924fa7453 to your computer and use it in GitHub Desktop.
Save Daenyth/f7bd4d7c9325f046322ad99924fa7453 to your computer and use it in GitHub Desktop.
Use a different ssh key for a specific github organization
# ~/.ssh/config
Match host github.com exec "[[ $(git remote get-url origin | sed 's/^.*://' | sed 's/\/.*//') = TheGithubOrganization ]]"
# Don't forget to ssh-add this in addition to other keys, or git will pick one that's already in the agent first
IdentityFile ~/.ssh/specific_rsa
@Daenyth
Copy link
Author

Daenyth commented Mar 10, 2022

@rjinski
Copy link

rjinski commented Apr 19, 2022

Nice but I assume this wont handle git clone ?

@Daenyth
Copy link
Author

Daenyth commented Apr 21, 2022

You're right - the answer on stack overflow linked above using gitconfig handles that though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment