随身笔记
随身笔记

Git多SSH Key共存问题

如果同时使用github和gitlab那就要考虑这个问题了。

1,配置用户名、邮箱

(1)GitHub配置,全局配置

$ git config --global user.name "zhouyang-cn"
$ git config --global user.email "lyzhou1107@163.com"

 

(2)GitLab配置,进入项目的根目录 (如果使用coding也要进入到根目录,像gitlab一样操作)

git config user.name "zhouyang"
git config user.email "zhouyang@xxx.com"

 

2,生成公钥

(1)github

ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C"lyzhou1107@163.com"

 

(2)GitLib

ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitlab -C"zhouyang@xxx.com"

命令执行完成后,这时~/.ssh目录下会多出id_rsa.github.pub和id_rsa.gitlab.pub文件就是给github和gitlab使用的公钥。

 

3,配置config文件

通过touch ~/.ssh/config命令创建config文件,修改文件内容如下:

#
# github
#
Host github.com  #只有输入IP就行不需要端口
IdentityFile ~/.ssh/id_rsa_github

#
# company gitlab
#
Host git.company.com
IdentityFile ~/.ssh/id_rsa_gitlab

 

配置完成以后,github的仓库会使用~/.ssh/id_rsa_github密钥进行验证,gitlab会使用~/.ssh/id_rsa_gitlab密钥进行验证。

ubuntu下使用git上传项目到github中

https://www.jianshu.com/p/95e00370fa2c

随身笔记

Git多SSH Key共存问题
如果同时使用github和gitlab那就要考虑这个问题了。 1,配置用户名、邮箱 (1)GitHub配置,全局配置 $ git config --global user.name "zhouyang-cn" $ git config --global user.…
扫描二维码继续阅读
2019-10-11