The authenticity of host ‘github.com (20.205.243.166)‘ can‘t be established.

目录

github初始化仓库,无法链接

解决无法与主机'github.com(20.205.243.166)'建立真实性

# 问题原因

# 生成密钥

# 物理路径 

# 建立交互

# 验证



 

 

github初始化仓库,无法链接

在github创建一个新的仓库时,如果我们未初始化,官方会提供命令行,如下: 

git add <file>...
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:gitname/example.git
git push -u origin main

如果你按照github官方指令敲打了一遍 ```bash```,却得到无法链接主机的提示:The authenticity of host 'github.com (20.205.243.166)' can't be established.

The authenticity of host 'github.com (20.205.243.166)' can't be established.
ED25519 key fingerprint is SHA256:example
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.


 

解决无法与主机'github.com(20.205.243.166)'建立真实性

# 问题原因

  1. 未与github.com建立链接关系(一般出现在新客户端,或重装系统的客户端)
  2. 与github.com建立的关系不匹配(被恶意篡改或其他用户使用替换了)

# 生成密钥

在命令行输入以下命令,youremail@example.com 需要改成你的github邮箱

ssh-keygen -t rsa -C "youremail@example.com"

具体实现,见下输出

PS D:\vinca\www> ssh-keygen -t rsa -C "youremail@example.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:ue8DrQkgc6SQVl12kx8YvtcODWM8WVzTyd88PW7bcec youremail@example.com
The key's randomart image is:
+---[RSA 2048]----+
| ..=+=o . .oo +. |
|o...B. o o  .= .o|
|.. *. . +     .o.|
|  + *..o.     . .|
|   + = .S.     *o|
|    . + ...   ..+|
|       o.+     .E|
|        o..      |
|         .o.     |
+----[SHA256]-----+
PS D:\vinca\www>

 

# 物理路径 

根据输出提示,已经告诉您。身份信息和公钥放在您电脑的 C:\Users\Administrator/.ssh/

打开 id_rsa.pub,复制里面的内容

# 建立交互

a. 打开github,登录你的邮箱用户 

Sign in to GitHub · GitHub

b. 进入个人中心的设置(Settings)选项

c. 创建新的 ssh 密钥

d. 根据提示,输入标识(title)、密钥(key)、密钥类型(key type)

这里的 key type 选择 Authentication key,因为我们刚刚通过命令产生的是身份识别文件 id_rsa

Your identification has been saved in C:\Users\Administrator/.ssh/id_rsa.

e. 确认添加(Add SSH key)后需要你验证一下当前用户密码,以此继续操作。

f. 添加成功后的示例

 

g. 回到你的编辑器(自带或集成git工具)[示例vscode],重新执行提交代码命令:

PS D:\vinca\www> git push -u origin main
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (10/10), 1.40 KiB | 717.00 KiB/s, done. 
Total 10 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:example.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.

显示提交到main分支成功了。

# 验证

通过以下链接,访问你的github项目仓库,记得*gitName*改成你的账户名,*remoteName*改成你的仓库名。

https://github.com/*gitName*/*remoteName*


相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-06-09 00:58:03       8 阅读
  2. 【Python教程】压缩PDF文件大小

    2024-06-09 00:58:03       9 阅读
  3. 通过文章id递归查询所有评论(xml)

    2024-06-09 00:58:03       10 阅读

热门阅读

  1. advices about writing promotion ppt

    2024-06-09 00:58:03       8 阅读
  2. KMeans聚类分析星

    2024-06-09 00:58:03       4 阅读
  3. 中介子方程七

    2024-06-09 00:58:03       6 阅读
  4. C++的封装(十二):外部构造函数

    2024-06-09 00:58:03       5 阅读
  5. 服务器硬件基础知识有哪些?

    2024-06-09 00:58:03       6 阅读
  6. Linux的命令补全脚本

    2024-06-09 00:58:03       6 阅读
  7. Android Camera APP预览画面镜像及旋转处理

    2024-06-09 00:58:03       7 阅读
  8. 请求分页存储管理方式

    2024-06-09 00:58:03       6 阅读
  9. Flink 容错

    2024-06-09 00:58:03       6 阅读
  10. 5、js关于数组的常用方法(19种)

    2024-06-09 00:58:03       5 阅读
  11. ubuntu,确认cudnn是否安装成功

    2024-06-09 00:58:03       7 阅读
  12. 富格林:有效杜绝被骗安全做单

    2024-06-09 00:58:03       6 阅读