1、linux操作
①在linux中输入
ssh-keygen -t rsa
②提示信息
Enter file in which to save the key (/home/用户目录/.ssh/id_rsa):直接enter不设置账号
Enter passphrase (empty for no passphrase):直接enter不设置密码
Enter same passphrase again:直接enter不设置密码
Your identification has been saved in /home/用户目录/.ssh/id_rsa.
Your public key has been saved in /home/用户目录/.ssh/id_rsa.pub.
③私密和公密都生成成功了,在以上目录
cat /home/用户目录/.ssh/id_rsa.pub
复制显示的内容
4、gitlab操作
①登录进入gitlab地址
②右上角头像出,点击下拉框,选择setting
③然后切换到ssh keys菜单
④在文本框粘贴刚才在linux复制的公钥
⑤点击add key按钮即可保存成功