Skip to content

Instantly share code, notes, and snippets.

@andersgoransson
Created January 28, 2019 13:36
Show Gist options
  • Save andersgoransson/b7d08cdbd787cfbcf3f9cd5b349db803 to your computer and use it in GitHub Desktop.
Save andersgoransson/b7d08cdbd787cfbcf3f9cd5b349db803 to your computer and use it in GitHub Desktop.
Setup multiple Github accounts

Personal notes on working towards two different Github-accounts on the same machine.

Prerequisite:

One default ssh-key already exists: ~/.ssh/id_rsa

Generate a named ssh-key:

ssh-keygen -t rsa -C "[email protected]" -f "id_rsa_my_user"

Copy the public ssh_key to the Github-account:

pbcopy < ~/.ssh/id_rsa_my_user.pub

Add key to ssh-agent:

ssh-add ~/.ssh/id_rsa_my_user

Update ~/.ssh/config file:

Host github.com-my_user (An identifier for this Github account. Used it local .git-config to locate repo.)
HostName github.com User git IdentityFile ~/.ssh/id_rsa_my_user

Reference Github-repo by using the Host from ssh config:

git clone [email protected]_user:github-username/repo_name.git

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