如何创建github公钥(基于最新的工具)

本文详细介绍了如何下载并安装Git,生成SSH密钥对,添加到GitHub,并通过SSH验证。适合新手了解Git基础设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、在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公钥的添加。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值