Skip to content

Instantly share code, notes, and snippets.

@loburets
Last active February 28, 2022 12:32
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 loburets/c8add517a4932894b440cb3b5b453282 to your computer and use it in GitHub Desktop.
Save loburets/c8add517a4932894b440cb3b5b453282 to your computer and use it in GitHub Desktop.
Switch ssh credentials to use another key for git when you use multiple accounts and return back
# to switch:
ssh-add -D && ssh-add ~/.ssh/id_rsa_personal
ssh-add -D && ssh-add ~/.ssh/id_rsa
ssh-add -D && ssh-add ~/.ssh/id_rsa_gmail
# to generate such file:
ssh-keygen -t ed25519 -C "dmitry.loburets@gmail.com" -f ~/.ssh/id_rsa_gmail
ssh-keygen -t ed25519 -C "dima-loburec@yandex.ru" -f ~/.ssh/id_rsa_personal
ssh-keygen -t ed25519 -C "Dmitry L for work" -f ~/.ssh/id_rsa
# to see public key
cat ~/.ssh/id_rsa_gmail.pub | pbcopy
cat ~/.ssh/id_rsa_personal.pub | pbcopy
cat ~/.ssh/id_rsa.pub | pbcopy
@loburets
Copy link
Author

loburets commented Feb 8, 2021

Helps if you have personal and work ssh keys on the same user

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