分享

一台电脑多个GITHUB账号设置

 yeching 2016-07-30
有时候因为自己需要,可能要在一台电脑上设置多个GIthub账号要在同一台电脑上给两个属于不同账号的仓库提交时。但是一把公钥只能被一个GITHUB账号拥有,因此必须为不同的账号创建不同的公钥进行配对。

方法步骤:
1.制作公钥
制造第一把公钥:
ssh-keygen -t rsa -C "yq08051035@163.com"
# 设置名称为id_rsa
Enter file in which to save the key (.ssh/id_rsa): id_rsa
 
 
制造第二把公钥:
ssh-keygen -t rsa -C "yq08051035@gmail.com"
# 设置名称为my
Enter file in which to save the key (.ssh/id_rsa): my
 
 
--------------------------------
2.把id_rsa.pub添加到后台SSH账户
查看文件是否存在
将id_rsa.pub添加到yq08051035@163.com账号的后台ssh。 
将my.pub添加到yq08051035@gmail.com账号的后台ssh。
  

3.在.ssh目录下配置config文件
Host github.com
  HostName github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa

Host my.github.com
  HostName github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/my

4.测试
ssh -T git@github.com
Hi yeching! You've successfully authenticated, but GitHub does not provide shell access.
 
 
ssh -T git@my.github.com
Hi aifusheng! You've successfully authenticated, but GitHub does not provide shell access.
说明OK。
 
 

当我们要在一个仓库上PUSH提交的内容时,先解析出仓库地址,然后从该仓库的所属账号中找到一把能解锁该提交的公钥。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多