I have 2 accounts on github, and here is what I did (on linux
) to make it work.
ssh-keygen
, name them properly, so that make life easier.ssh-add path_to_private_key
~/.ssh/config
Host github-kc
Hostname github.com
User git
IdentityFile ~/.ssh/github_rsa_kc.pub
# LogLevel DEBUG3
Host github-abc
Hostname github.com
User git
IdentityFile ~/.ssh/github_rsa_abc.pub
# LogLevel DEBUG3
Set remote url for repo:
For repo in Host github-kc
:
git remote set-url origin git@github-kc:kuchaguangjie/pygtrans.git
For repo in Host github-abc
:
git remote set-url origin git@github-abc:abcdefg/yyy.git
Options in ~/.ssh/config
:
Host
github-<identify_specific_user>
Host could be any value that could identify a host plus an account,
it don't need to be a real host,
e.g
github-kc
identify one of my account on github for my local
laptop,
When set remote url for a git repo, this is the value to put after git@
, that's how a repo maps to a Host, e.g git remote set-url origin git@github-kc:kuchaguangjie/pygtrans.git
Host
]Hostname
github.com
for github,User
git git
for github,IdentityFile
LogLevel
DEBUG3
gives the most detailed info.