Multi-Platform and Multi-Repository Usage
Index
Scenario
Your personal project and the company project may not be on the same hosting platform, but you need to develop on a single machine.
- Create key pairs for different hosting platforms.
ssh-keygen -t ed25519 -C "JerryTZF@github.com" -f ~/.ssh/id_github
ssh-keygen -t ed25519 -C "JerryTZF@gitlab.com" -f ~/.ssh/id_gitlab
ssh-keygen -t ed25519 -C "JerryTZF@gitee.com" -f ~/.ssh/id_gitee
- Add private keys of different platforms to the ssh-agent
ssh-add ~/.ssh/id_github
ssh-add ~/.ssh/id_gitlab
ssh-add ~/.ssh/id_gitee
- Write the configuration file
vim ~/.ssh/config
# company
Host gitee.com
HostName gitee.com
User JerryTZF
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_company
# myself
Host github.com
HostName github.com
User JerryTZF
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_myself
- Test
ssh -T git@github.com
ssh -T git@gitee.com