ubuntu18.04同时配置公司内网gitlab和公网github

配置公司内网gitlab

1. ssh-keygen -t rsa -C "gitlab邮箱" -f ~/.ssh/gitlab_id-rsa
2. cat gitlab_id-rs.pub 粘贴到setting
3. ssh -T [email protected]  其中192.168.1.110为公司内网地址

配置公网github

1. ssh-keygen -t rsa -C "github邮箱" -f ~/.ssh/github_id-rsa
2. cat github_id-rs.pub 粘贴到setting
3. ssh -T [email protected]  

创建config兼容二者

touch ~/.ssh/config

config内容如下:
Host github
    Port 22
    User *** 
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/github_id-rsa
Host gitlab
    Port ***
    User ***
    HostName 192.168.1.110 
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/gitlab_id-rsa

git config配置

gitlab经常使用:
git config --global user.name="gitlab user name"
git config --global user.email="gitlab email name"

github偶尔使用:
cd github project
git config --local user.name="github user name"
git config --local user.email="github email name"

你可能感兴趣的:(ubuntu18.04同时配置公司内网gitlab和公网github)