Skip to content

Instantly share code, notes, and snippets.

@nguyenhoaibao
Last active March 19, 2018 04:13
Show Gist options
  • Save nguyenhoaibao/a5dd09c30edc49d5cc79f6bba2709a35 to your computer and use it in GitHub Desktop.
Save nguyenhoaibao/a5dd09c30edc49d5cc79f6bba2709a35 to your computer and use it in GitHub Desktop.
Using multiple keys with multiple repos
  • Gen 2 or multiple keys
ssh-keygen -t rsa -C key01@example
ssh-keygen -t rsa -C key02@example
  • Setup ssh config
Host repo01
   HostName <github.com, bitbucket.com...>
   IdentityFile /path/to/key01
Host repo02
   HostName <github.com, bitbucket.com...>
   IdentityFile /path/to/key02
  • Setup repo

    • New repo

 GIT_SSH_COMMAND='ssh -i /path/to/key01' git clone git@github.com:SpoutEntertainment/repo01.git

 GIT_SSH_COMMAND='ssh -i /path/to/key02' git clone git@github.com:SpoutEntertainment/repo02.git

  • Existing repo

 git remote set-url origin git@repo01:SpoutEntertainment/repo01.git

 git remote set-url origin git@repo02:SpoutEntertainment/repo02.git

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