公司个人git混合使用

场景

公司内网部署了git,同时想使用github做其他项目

开始

1、生成git密钥

右键鼠标,选择“Git Bash Here”
ssh-keygen -t rsa -C "[email protected]"

出现如下后输入即将生成的文件名称,例如:id_rsa_my_github,然后按回车两次生成文件

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Dell/.ssh/id_rsa):

公司个人git混合使用_第1张图片
此时应该生成两个文件,分别是“id_rsa_my_github”和“id_rsa_my_github.pub”
1、如果公司已经提供了私钥就不需要生成了
2、可选 -> 如果还需使用gitee或者开源中国,再生成两个密钥即可,那么一共就是6个文件
3、把这些文件复制到 C:\Users\Dell\.ssh 下

2、添加SSH key到 ssh-agent

进入C:\Users\Dell\.ssh文件夹,然后按住shift键选择Git Bash Here,依次输入

ssh-agent bash
ssh-add ~/.ssh/id_rsa 						#假如这个是公司的ssh key
ssh-add ~/.ssh/id_rsa_my_github	#假如这个是你为github生成 ssh key
ssh-add ~/.ssh/id_rsa_my_osc		#假如这个是开源中国的ssh key
git config --global ssh.variant ssh	#刷新ssh agent
3、新建config文件

在这文件夹里新建一个文件,名称为config,不要后缀,然后文档打开

#github
		Host github.com    
		HostName github.com
		IdentityFile ~/.ssh/id_rsa_my_github
		User 你的名称

#osc
#Host gitee.com
#HostName gitee.com
#IdentityFile ~/.ssh/id_rsa_osc
#User pinnuli

#company
#输入公司ip端口,或者域名
		Host 192.168.168.168:8888
		HostName company
		IdentityFile ~/.ssh/id_rsa
		User 你的名称
5、公钥使用

然后我们来处理*.pub ssh key,这些用文档模式查看,内容开头为“ssh-rsa”,全选复制,进入到github账号,依次进行如下操作:
公司个人git混合使用_第2张图片
公司个人git混合使用_第3张图片

公司个人git混合使用_第4张图片
在框里粘贴刚才复制的内容,以ssh-rsa开头公司个人git混合使用_第5张图片
结束

参考

Generating a new SSH key and adding it to the ssh-agent
git多账号配置,同时使用多个代码托管平台
github|fatal:unable to access|OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com 443

你可能感兴趣的:(Android)