通常用法
|
|
同时使用多个账户
首先还是生成 SSH-Key:
|
|
理论上应该可以共用同一对密钥吧,但是这样安全性就……
多敲几行复制粘贴几次又费不了多大劲,万一不小心把私钥暴露出去了,损失会小很多。
拿 RSA 密钥对撞库是我未曾设想的道路。
vim ~/.ssh/config
编辑配置文件:
# Default Github User(Github User [email protected])
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_ssh_key
# Another Github User(Github User2 [email protected])
Host github.com-2
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_ssh_key_2
# Default Gitee User(Gitee User [email protected])
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_ssh_key
默认账户没什么好说的,需要注意第二个 github 账户应该使用:
[email protected]:<USERNAME>/<REPONAME>.git
重点是里面的 github.com-2
应该对应 config
配置文件里的 Host
。
可以自行替换。比如换成 p**nhub.com
设置完成后依次测试连通性:
|
|
实际使用
众所周知把本地分支推送到远程应该:
|
|
所以同时使用 Gitee 的话:
|
|