美文网首页
【版本控制】一台电脑多账号多Git连接学习

【版本控制】一台电脑多账号多Git连接学习

作者: JankinWa | 来源:发表于2019-03-04 23:30 被阅读0次

  在.ssh目录中生成多个对应的公私钥,多次操作时注意取不同的名字,密码可以直接为空

ssh-keygen -t rsa -C "youremail@email.com"

创建config文件,并加入配置内容

touch config
vi config
#################
Host github.com
    HostName github.com
    IdentityFile ~/.ssh/id_rsa_github
Host gitee.com
    HostName gitee.com
    IdentityFile ~/.ssh/id_ras_gitee

agent中添加私钥

## 进入agent
ssh-agent bash
## 查看已添加ras
ssh-add -l
## 添加私钥
ssh-add id_ras
## 删除私钥
ssh-add -D **

在Github、码云等中添加SSH Key,拷贝公钥进去即可

完成上述步骤后,可以简单测试一下

ssh -T gitee.com
ssh -T git@github.com

   
多个账号同样操作

相关文章

网友评论

      本文标题:【版本控制】一台电脑多账号多Git连接学习

      本文链接:https://www.haomeiwen.com/subject/vecguqtx.html