1. 生成key
輸入以下命令:
ssh-keygen -t rsa -C "your email"

image.png
如圖已經生成成功,打開路徑C:\Users\your account\.ssh會有兩個文件:
? ?id_rsa:私鑰
? ?id_rsa.pub:公鑰
1.1 出現(xiàn)以下提示信息,可直接按回車 (默認是C:\Users\your account.ssh\id_rsa)
Enter file in which to save the key (/c/Users/Thinkpad/.ssh/id_rsa):
1.2 提示輸入密碼,這里我沒有輸入密碼(如果不輸入密碼,SSH是無密碼連接),直接回車兩次。
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
2. 關聯(lián)GitHub

image.png
如下圖所示把生成的公鑰文件內容復制到Key中,然后Add SSH key.

image.png

image.png
3. 測試git與GitHub連接是否成功
輸入以下命令:
ssh -T git@github.com
如果成功,命令行出現(xiàn)下圖所示的信息。

image.png