天天看點

Git 配置SSH公鑰、私鑰

開篇日常立個flag....

安裝Git

此處略去一萬字

了解幾個東西

為什麼要配置公鑰、私鑰?配置了有什麼用(對于Git)?怎麼配置?

(以後補充)

Git 配置SSH公鑰、私鑰

1、進入Git Bash

滑鼠右鍵<Git Bash Here>(或者檔案路徑裡敲<Git Bash.lnk>)

2、輸入生成 Rsa 秘鑰對的指令

ssh-keygen -t rsa -C "[email protected]"

3、秘鑰名稱

Enter file in which to save the key (/c/Users/CL/.ssh/id_rsa): <輸入秘鑰名稱/直接回車>

注:本例中,輸入秘鑰名稱為:lisheng741

4、輸入密碼和确認密碼

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

都可空,直接回車,等待生成秘鑰對。

本地會生成兩個檔案:

lisheng741     私鑰

lisheng741.pub   公鑰

5、本地添加私鑰

ssh-add <私鑰路徑>

6、讀取公鑰

方式1:cat <公鑰檔案>

方式2:以文本方式打開公鑰檔案

将公鑰文本複制,用于下一步

7、在 Github / Gitee 添加公鑰

Github:點自己頭像 >> Settings >> SSH and GPG keys >>New SSH key 

Gitee:點自己頭像 >> 設定 >> SS公鑰 

參考來源

https://blog.csdn.net/july_young/article/details/82712574 (july_young 的 git添加私鑰)

https://www.cnblogs.com/kaerxifa/p/11164206.html (wangju003 的 git配置密鑰(私鑰、ssh、公鑰))

Git配置SSH公鑰、私鑰 踩坑記錄

第5步本地添加私鑰時,提示:

Could not open a connection to your authentication agent.

具體原因沒有細究,解決方案:先執行指令:ssh-agent bash

https://www.cnblogs.com/sheldonxu/archive/2012/09/17/2688281.html (Sheldon Xu 的 執行ssh-add時出現Could not open a connection to your authentication agent)

繼續閱讀