问题描述:公司电脑上默认使用的是公司的github账号,如果希望写一些代码放到个人的github账号上,就需要配置让一个电脑上可以使用两个github账号

原理:管理两个SSH key

1.生成两个SSH KEY

为个人账户生成SSH KEY:

ssh-keygen -t rsa -C "your-self-email-address" -f /c/Users/Administrator/.ssh/id_rsa

为公司github账户生成SSH KEY:

$ ssh-keygen -t rsa -C "your-work-email-address" -f /c/Users/Administrator/.ssh/id_rsa_work

2.分别把id_rsa.pub和id_rsa_work.pub中的内容加到对应github的账号中,添加到Settings的SSH and GPG Keys中

3.把key加到ssh agent上

$ ssh-add ~/.ssh/id_rsa
$ ssh-add ~/.ssh/id_rsa_work

可以通过ssh-add -l来确认结果

4.配置.ssh/config

#one(self-email@.com)
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
User one #two(work-email@xxx.com)
Host github_work.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_work
User two

5.在~/.ssh下运行

$ ssh git@github.com

或者
$ssh git@github_work.com

5.这样github.com对应的是自己的gihub账号,github_work.com对应的是公司的github账号

$ git init
$ git commit -m 'xxxx' #push到github上
$ git remote add origin git@github.com:xxxx/test.git
$git push origin master

最新文章

  1. delphi 实现最小化系统托盘
  2. 【转载】Tomcat崩溃事件
  3. OpenWRT连接OPENVPN的教程
  4. How I came to find Linux
  5. wpa_cli调试工具的使用
  6. 浙江大学PAT上机题解析之1015. 德才论 (25)
  7. TextView SpannableString 使用之实现可点击超链接效果
  8. BZOJ 2631: tree [LCT splay区间]
  9. rabbitmq之基本原理及搭建单机环境
  10. Android的Activity组件
  11. Spring Boot 全文搜索引擎 ElasticSearch
  12. ORA错误总结
  13. oracle自定义函数返回结果集
  14. c++中运算符重载
  15. react缓存问题
  16. MongoDB 进程控制系列二:结束进程
  17. 基于CentOS搭建私有云服务
  18. Git 安装(分布式版本控制系统)
  19. Bootstrap 网格系统(Grid System)的工作原理 - 媒体查询
  20. NuGet 让程序集版本变得混乱

热门文章

  1. npm 发布包和删除包(2019最新攻略)
  2. 游戏行业DDoS攻击解决方案
  3. 【翻译】Apache Shiro10分钟教程
  4. python – 基于pandas中的列中的值从DataFrame中选择行
  5. shell 十进制数字转十六进制字符串并将结果保存到变量
  6. docker容器运行与退出
  7. poi操作Excel的封装类
  8. bash python获取文本中每个字符出现的次数
  9. java.lang.NoClassDefFoundError: javax/annotation/Priority
  10. 教你如何让数据库支持emoji表情符存储