scenario
Github, Gitee, the company’s GitLab/Gerrit, etc. It requires a seamless transition between work and study.
1. Open the terminal and switch to the SSH directory of the system
cd ~/.ssh
2. Generate an SSH Key for Github
Ssh-keygen -t rsa -c “email address” -f github_rsa Note: The -f parameter is followed by the user-defined key name, which is used to distinguish different Git platforms.
3. Enter the Github account password
4. Obtain the Github SSH public key
cat ~/.ssh/github_rsa.pub
Create other Git platform accounts in the same way
5. Add the config file (if yes, edit it; if no, go to ~/.ssh/config) and write the configuration as follows:
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_rsa
# gitlab
Host gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/company_rsa
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_rsa
Copy the code
Note: the Host name can be set arbitrarily. HostName is the address of the website. For example, the Gitlab Host address is http://10.10.10.89:11000, then HostName is 10.10.10.89
6. Configure the SSH key on github/gitee/gitLab
gitee
github
gerrit
7. Test whether the connection is normal
ssh -T [email protected] is a success…