生成一个ssh key
ssh-keygen -t rsa -C “xxx@aabb.com” # 根据你的邮箱采用rsa非对称算法生成一个ssh的公钥和私钥
将生成的私钥加入到ssh中
ssh-add ~/the/private/key # 后面填写私钥的路径
配置ssh
TCPKeepAlive=yes
ServerAliveInterval 60
# gitlab
Host gitlab.xxx.com # your gitlab hostname
port 22
HostName gitlab.xxx.com
PreferredAuthentications publickey
IdentityFile ~/.ssh_gitlab/rsa.pub
User yourGitLabName
# github
Host github.com
Port 22
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/rsa.pub
User yourGitHubName
来源:CSDN
作者:小飞猪0_0
链接:https://blog.csdn.net/qq_38377846/article/details/104757691