Git plurality SSH Key

Usually because of security and multi-platform, we'll git configure different SSH key. In this paper, GitLab and GitHub as an example:

After opening the git program:

The first step: switch to SSH directory 

cd ~/.ssh

 Step Two: gitlab and generate a corresponding public key github of SSH (note alternative mail):

ssh-keygen -t rsa -C "[email protected]" -f gitlab_id_rsa
ssh-keygen -t rsa -C "[email protected]" -f github_id_rsa

The third step: create a new profile config (suffix does not need, in the .ssh directory)

Says:

# gitlab
Host gitlab.com
    HostName gitlab.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/gitlab_id_rsa
# github
Host github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/github_id_rsa
  ​
# 配置文件参数
# Host : Host可以看作是一个你要识别的模式,对识别的模式,进行配置对应的的主机名和ssh文件
# HostName : 要登录主机的主机名
# User : 登录名
# IdentityFile : 指明上面User对应的identityFile路径
# 如果gitlab的不是域名是ip也可以

Step Four: Test

ssh -T [email protected]

If the domain name is changed after ip ip can put @

Attachment: Open gitlab_id_rsa.pub file .ssh folder, copy the contents to GitLab the (github empathy) to add key, you can associate success

 

 

Published 95 original articles · won praise 43 · views 70000 +

Guess you like

Origin blog.csdn.net/lyxuefeng/article/details/105047740