第一步:进入ssh文件夹
$:cd ~/.ssh
第二步:获取git的密钥
$:ssh-keygen -t rsa -b 4096 -C "email@email.com" -f id_rsa_github
id_rsa_github:是密钥文件
第三步:复制密钥
$:clip < ~/.ssh/id_rsa_github.pub
第四步:需要在.ssh文件夹下面创建config文件
Host github.com
HostName github.com
User user1
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_ras_github ## 这个是创建的密钥文件
如果有多个的话,可以复制多份
Host github.com HostName github.com User user1 PreferredAuthentications publickey IdentityFile ~/.ssh/id_ras_github1
Host github.com HostName github.com User user1 PreferredAuthentications publickey IdentityFile ~/.ssh/id_ras_github2 |
第五步:
git clone git@gitlab.xxx.com:second/test.git