栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

搭建github-ssh连接时,Could not resolve hostname github的解决方案(无法ping通github)

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

搭建github-ssh连接时,Could not resolve hostname github的解决方案(无法ping通github)

解决无法 ping 通 github.com 的问题

测试平台:Windows 10

测试时间: 2022年3月4日

问题描述:

​ 笔者在进行搭建本地 git 时,需要通过 ssh 建立与 github 的连接,在进行ssh连接验证时,出现如下提示

ssh: Could not resolve hostname github.com: Name or service not known

​ 此时对目标地址进行 ping 操作如下

ping github.com

出现如下错误提示(git bash)

Ping request could not find host github.com. Please check the name and try again.

windows的cmd 我没复制,但大致提示无法访问远程主机,连接不可建立

解决方案:

首先获取 github.com IP 地址

IP 地址查询: Click

通过上述网站查询得到 github.com IP 地址如下

140.82.113.4

此时修改本地 DNS 文件 C:WindowsSystem32driversetc 目录下的 hosts 文件

由于该文件在 C 盘中,无法直接打开进行修改,需要使用管理员权限

此处操作方式为,搜索 记事本 软件,右键以管理员身份运行

通过左上角文件->打开,选择上述 hosts 文件打开,在文件内容最下方加入一行

140.82.113.4    github.com

完成后保存即可。

此时再次 ping github.com 即可看到能够成功 ping 通

$ ping 140.82.113.4

Pinging 140.82.113.4 with 32 bytes of data:
Reply from 140.82.113.4: bytes=32 time=229ms TTL=42
Reply from 140.82.113.4: bytes=32 time=229ms TTL=42
Reply from 140.82.113.4: bytes=32 time=229ms TTL=42
Reply from 140.82.113.4: bytes=32 time=229ms TTL=42

Ping statistics for 140.82.113.4:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 229ms, Maximum = 229ms, Average = 229ms
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/945986.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号