一、在https://git-scm.com/downloads下载git工具.


二、双击下载的安装文件,比如Git-2.28.0-64-bit.exe,安装完后找到Git Bash应用打开。

三、创建公钥
1. 确定之前是否生成过公钥。
Administrator@XXX MINGW64 ~
$ cd ~/.ssh
bash: cd: /c/Users/Administrator/.ssh: No such file or directory
2. 用 ssh-keygen -t rsa -C "xxx@mail.cn"命令生成公钥。
Administrator@XXX MINGW64 ~
$ ssh-keygen -t rsa -C "xxx@mail.cn"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Created directory '/c/Users/Administrator/.ssh'.
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:S+lEADBXXXXc5aOYPIVQQQQQGqfxBS88888888aj/DLQaDc xxx@mail.cn
The key's randomart image is:
+---[RSA 3072]----+
| o.o=o+. |
|........ |
|++++o+ o . o |
|+.o.* + + + |
| 000 + o0 . |
|o O o .o.o |
| * |
| |
| |
+----[SHA256]-----+
3. 在github添加公钥


将id_rsa.pub的内容copy即可:

4. 用【ssh -T git@github.com】验证是否成功,如下,就是成功。注意:第一次测试需要输入[yes]。
Administrator@XXX MINGW64 ~/.ssh
$ ssh -T git@github.com
The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is SHA256:E1IGOgnThbGl89kXKw6E5SUpJWCspRomTx9537LviY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
Hi xxxxx! You've successfully authenticated, but GitHub does not provide shell access.
Administrator@XXX MINGW64 ~/.ssh
$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '13.229.188.59' to the list of known hosts.
Hi xxxxx! You've successfully authenticated, but GitHub does not provide shell access.
5. 至此就完成了github公钥的添加。
本文详细介绍了如何下载并安装Git,生成SSH密钥对,添加到GitHub,并通过SSH验证。适合新手了解Git基础设置。
630

被折叠的 条评论
为什么被折叠?



