Skip to content

Instantly share code, notes, and snippets.

@nnnikolay
Last active June 2, 2016 11:55
Show Gist options
  • Save nnnikolay/d97f55a27ab01585a1c5 to your computer and use it in GitHub Desktop.
Save nnnikolay/d97f55a27ab01585a1c5 to your computer and use it in GitHub Desktop.
use github with different accounts

Multiple github accounts

  • Make some changes in .ssh/config file
Host github-public
	HostName github.com
	User git
	IdentityFile /Users/username/.ssh/id_rsa_public_account
	IdentitiesOnly yes

Host github-office
	HostName github.com
	User git
	IdentityFile /Users/username/.ssh/id_rsa
	IdentitiesOnly yes
  • Make sure that those keys are added into ssh-agent.
ssh-agent /paht/to/key_from_public_account
ssh-agent /paht/to/key_from_office

After osx restart those records will gone, so to keep them just call ssh_agent -K <key> to store it in keychain

  • Last step is change repo in .git/config
[remote "origin"]
	url = ssh://git@github-office/path/to/repo.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment