使用環境
window7系統
環境
git軟件(攜帶的bash終端類似linux的終端很好用建議安裝)
有一個可用的github賬號
1. 先生成需要的PUBLIC KEY
打開bash
軟件執行如下命令
ssh-keygen -t rsa
指定生成key的路徑名稱,一路回車即可
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/lenovo/.ssh/id_rsa): /c/Users/lenovo/.ssh/id_rsa_github_hexo
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/lenovo/.ssh/id_rsa.
Your public key has been saved in /c/Users/lenovo/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ULsfGWCKY1aJqFQ24QkUxuPu3TiBqoJHXy6mHpQ/i0k lenovo@lenovo-PC
The key's randomart image is:
+---[RSA 2048]----+
|o=o*....+ |
|.+= +o.+ o |
|o..o= o . . |
|.. + . . . o |
|. + S o |
| +.o . . . |
|+.E.*o . |
|+o.B++. |
|+o=oo. |
+----[SHA256]-----+
這樣我們就在~/.ssh
路徑下生成兩個文件id_rsa
和id_rsa.pub
$ ll ~/.ssh
total 15
-rw-r--r-- 1 lenovo 197121 114 九月 19 14:32 config
-rw-r--r-- 1 lenovo 197121 1679 九月 17 14:58 id_rsa
-rw-r--r-- 1 lenovo 197121 398 九月 17 14:58 id_rsa.pub
2. 打開github的 ssh 管理頁面把 對應的公鑰提交保存到代碼管理服務器 (.pub 結尾)
在終端執行
cat id_rsa.pub
github
具體位置在 點擊賬戶的Settings
中的SSH and FPG keys
點擊New SSH key
綠色按鈕 輸入自己本地id_rsa_github_hexo.pub
中的內容
3. 測試配置完畢后是否可以ssh訪問github
$ ssh -T git@github.com
Hi qnyt1993! You've successfully authenticated, but GitHub does not provide shell access.
這里表明已經可以了,配置結束