1. 安裝git,比如TortoiseGit,
從程序目錄打開 "Git Bash" (或是打開c\user\win10)
2. 鍵入命令:ssh-keygen -t rsa -C "email@email.com" 或輸入(
ssh-keygen)
"email@email.com"是github賬號
C:\Users\win10>ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/win10/.ssh/id_rsa):
Created directory '/c/Users/win10/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/win10/.ssh/id_rsa.
Your public key has been saved in /c/Users/win10/.ssh/id_rsa.pub.
The key fingerprint is:
e6:21:ab:cb:16:2e:c3:42:db:18:06:ff:00:f3:72:0a win10@WIN-TA017Q0H1IP
The key's randomart image is:
+--[ RSA 2048]----+
|o..o+ |
| o.o.+ |
|E.o=o . |
|. +oo |
| . .. . S |
| o = . |
| + . . |
| .o. |
| .+. |
+-----------------+
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/win10/.ssh/id_rsa):
Created directory '/c/Users/win10/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/win10/.ssh/id_rsa.
Your public key has been saved in /c/Users/win10/.ssh/id_rsa.pub.
The key fingerprint is:
e6:21:ab:cb:16:2e:c3:42:db:18:06:ff:00:f3:72:0a win10@WIN-TA017Q0H1IP
The key's randomart image is:
+--[ RSA 2048]----+
|o..o+ |
| o.o.+ |
|E.o=o . |
|. +oo |
| . .. . S |
| o = . |
| + . . |
| .o. |
| .+. |
+-----------------+
3. 提醒你輸入key的名稱,輸入如id_rsa(
直接按回車鍵)
4. 在C:\Users\win10\.ssh\下產生兩個文件:id_rsa和id_rsa.pub
5. 如果在win10下生成的文件,請把4中生成的密鑰文件復制到C:\Users\win10\.ssh\ 目錄下。
6. 用記事本打開id_rsa.pub文件,復制內容,在github.com的網站上到ssh密鑰管理頁面,添加新公鑰,隨便取個名字,內容粘貼剛才復制的內容。
7. ^_^ OK了
需要注意步驟2中產生的密鑰文件在當前用戶的根目錄,必須把這兩個文件放到當前用戶目錄的“.ssh”目錄下才能生效。
在windows中只能在命令行下輸入創建"."開頭的文件夾。命令為 mkdir .ssh
轉載:http://www.cnblogs.com/igrl/archive/2010/09/17/1829358.html