Mac系統下查看和生成SSH Key

1、打開vim(terminal.app)查看本地是否存在SSH-Key

 

  # ls -al ~/.sshvim

 

>> 若是vim輸出的是以下內容:證實本地沒有生成的SSH Key,請執行第二步。app

 

  # No such file or directoryssh

 

>> 若是vim輸出的是以下內容: 證實本地已經存在SSH Key 文件,請執行第四步。terminal

 

  # id_rsa        id_rsa.pubit

 

2、若是沒有,生成新的SSH Key

 

  #ssh-keygen -t rsa -C"you_email"email

 

your_email:這裏填寫你在GitLab或者GitHub註冊時的郵箱。file

 

後面的提示直接敲回車,一路完成。rsa

 

3、生成並添加SSH Key

 

  # ssh-add ~/.ssh/id_rsaim

 

4、查看SSH Key

 

  # cat /Users/xxx/.ssh/id_rsa.pubssh-key

 

xxx是你的電腦用戶名,例如:howieMacBook-Pro:~ howie$中的howie關鍵字。

 

複製生成好的SSH Key 添加到 GitLab 或者GitHub中的SSH Key中便可。

相關文章
相關標籤/搜索