Skip to content

Instantly share code, notes, and snippets.

@xiaolai
Created October 21, 2021 01:46
Show Gist options
  • Save xiaolai/10f5d8f664919716b70a378e5d6769ea to your computer and use it in GitHub Desktop.
Save xiaolai/10f5d8f664919716b70a378e5d6769ea to your computer and use it in GitHub Desktop.
multiple account on github with ssh-key

In Terminal:

ssh-keygen -t rsa -f "id_rsa_<new account name>" -C "<email of new account>"
ssh-add ~/.ssh id_rsa_<new account name>

Edit ~/.ssh/config:

Host <hostname for new account>
    HostName github.com
    IdentityFile ~/.ssh/id_rsa_<new account name>

Clone repository:

git clone git@<hostname for new account>:<github account name>/<repository name>.git
cd <repository name>
git config user.name "<new account name>"
git config user.email "<email of new account>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment