windows下生成ssh key详解

1、本地成功安装了git后,单击鼠标右键,选择Git Bush here,打开git bush。

2、 键入命令:ssh-keygen -t rsa -C "[email protected]",引号中是你在github/gitee上的注册邮箱,之后设定你的ssh密码,如图:

连续按 三次enter键。 


Administrator@SC-201805190058 MINGW64 /d/phpstudy_pro/WWW/github20191209 (master)
$ ssh-keygen -t rsa -C "*******@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:sYdBnHEU/HhBkbRX87eXg4jffxCyAWl+c2ZOdSgwDUU [email protected]
The key's randomart image is:
+---[RSA 2048]----+
|       .o=B@Eo o.|
|       .o.=.=...=|
|        oo +.o..+|
|         =+ O.B +|
|        S..+ % =.|
|         .. o o o|
|           . . . |
|              . .|
|               ..|
+----[SHA256]-----+

Administrator@SC-201805190058 MINGW64 /d/phpstudy_pro/WWW/github20191209 (master)
$ eval "ssh-agent -s"
SSH_AUTH_SOCK=/tmp/ssh-U3PTzE21YO3O/agent.5760; export SSH_AUTH_SOCK;
SSH_AGENT_PID=5764; export SSH_AGENT_PID;
echo Agent pid 5764;

$ ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.
Administrator@SC-201805190058 MINGW64 /d/phpstudy_pro/WWW/github20191209 (master)
$ ssh-agent bash

Administrator@SC-201805190058 MINGW64 /d/phpstudy_pro/WWW/github20191209 (master)
$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/Administrator/.ssh/id_rsa ([email protected])

将key添加到github账户中去:

1.用vim复制key的内容:vim ~/.ssh/id_rsa.pub,右键复制出现的内容,如图:

2.将刚才的复制的keys粘贴即可。

windows下生成ssh key详解_第1张图片

随后在控制台上测试一下 

 ssh -T [email protected]
The authenticity of host 'github.com (13.229.188.59)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
Hi etianhai! You've successfully authenticated, but GitHub does not provide shell access.

 说明验证成功了

你可能感兴趣的:(git)