Git 多公钥配置
1 min
解决一个公钥无法共用问题
生成第一个密钥
ssh-keygen -t rsa -C "[email protected]"
生成第二个公钥
two_git
是第二个公钥的名称ssh-keygen -t rsa -C "[email protected]" -f two_git
在
.ssh
目录新建config
文件windows
下的.ssh
目录 在C:\Users\username
config
文件配置# 账号一Host gitee.com HostName gitee.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa HostkeyAlgorithms +ssh-rsa PubkeyAcceptedAlgorithms +ssh-rsa # 账号二# giteeHost two.gitee.com HostName gitee.com PreferredAuthentications publickey IdentityFile ~/.ssh/two_git HostkeyAlgorithms +ssh-rsa PubkeyAcceptedAlgorithms +ssh-rsa
使用
ssh
的方式克隆仓库使用账号一克隆代码
git clone [email protected]:xxxxxxx
使用账号二克隆代码
git clone [email protected]:xxxxxxx
完。