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按鈕即可保存成功