0

I couldn't find a definitive yes/no for this, so I thought I'd ask. Let's say I have two GitHub accounts, one for work, one for personal both sharing the same SSH key.

Let's say I sign into my work GitHub. If I clone a git repo using SSH, create a local branch, and push up my changes, does it automatically push to my work account with my work credentials, rather than my personal, even though both share the same SSH key? Thanks!

Brandon6
  • 31
  • 4
  • See https://stackoverflow.com/a/8483960/7976758 Found in https://stackoverflow.com/search?q=%5Bgithub%5D+multiple+accounts – phd Jun 18 '20 at 20:29

1 Answers1

1

You cannot use the same SSH key for multiple accounts. GitHub determines which account you're using by looking at the SSH key you use to perform the operation, so an SSH key must uniquely identify an account and cannot be shared. For similar reasons, deploy keys must also be unique and independent from SSH keys associated with an account.

So if you clone a repository associated with one account's SSH key, then it is likely that you will also use the same SSH key to push, although there are of course ways to use a different key and hence a different account.

The Git FAQ describes how to set up your environment to use multiple SSH keys and hence multiple accounts by giving each account a separate alias.

bk2204
  • 64,793
  • 6
  • 84
  • 100