拉取・克隆代码时提示Could not resolve host: [github.com]

拉取・克隆代码时提示Could not resolve host: github.com

sudo git pull
fatal: unable to access 'https://github.com/hst-bridge/AmazonRanking.git/': Could not resolve host: github.com

dig github.com・ping github.com

如果第三步没有返回结果,那应该时域名没有解析出来

azureuser@prod-vm-ranking:~/AmazonRanking$ dig github.com

#第一部分是综述,说明此次命令一共查询了几次,有几个回答。
; <<>> DiG 9.10.6 <<>> github.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7758
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 8, ADDITIONAL: 15

#第二部分是 QUESTION SECTION,即说明此命令发送了什么样的指令。
#这里表示我们询问 github.com 域名的 A 记录。
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;github.com.			IN	A

#第三部分是 ANSWER SECTION,即说明此命令执行后返回的结果。
#这里的结果表明 github.com 域名的 A 记录指向了 13.114.40.48 这个 IP。
;; ANSWER SECTION:
github.com.		5	IN	A	13.114.40.48

;; AUTHORITY SECTION:
github.com.		65597	IN	NS	dns4.p08.nsone.net.
github.com.		65597	IN	NS	ns-1283.awsdns-32.org.
github.com.		65597	IN	NS	ns-421.awsdns-52.com.
github.com.		65597	IN	NS	dns3.p08.nsone.net.
github.com.		65597	IN	NS	ns-1707.awsdns-21.co.uk.
github.com.		65597	IN	NS	ns-520.awsdns-01.net.
github.com.		65597	IN	NS	dns1.p08.nsone.net.
github.com.		65597	IN	NS	dns2.p08.nsone.net.

;; ADDITIONAL SECTION:
dns1.p08.nsone.net.	70078	IN	AAAA	2620:4d:4000:6259:7:8:0:1
dns2.p08.nsone.net.	69725	IN	AAAA	2a00:edc0:6259:7:8::2
dns3.p08.nsone.net.	45603	IN	AAAA	2620:4d:4000:6259:7:8:0:3
dns4.p08.nsone.net.	45554	IN	AAAA	2a00:edc0:6259:7:8::4
ns-421.awsdns-52.com.	90285	IN	AAAA	2600:9000:5301:a500::1
ns-520.awsdns-01.net.	90286	IN	AAAA	2600:9000:5302:800::1
ns-1283.awsdns-32.org.	90286	IN	AAAA	2600:9000:5305:300::1
dns1.p08.nsone.net.	70078	IN	A	198.51.44.8
dns2.p08.nsone.net.	69725	IN	A	198.51.45.8
dns3.p08.nsone.net.	45603	IN	A	198.51.44.72
dns4.p08.nsone.net.	133594	IN	A	198.51.45.72
ns-421.awsdns-52.com.	90285	IN	A	205.251.193.165
ns-520.awsdns-01.net.	90286	IN	A	205.251.194.8
ns-1283.awsdns-32.org.	90286	IN	A	205.251.197.3

#第四部分是总结,即说明此次查询的一些信息,
#例如:查询耗时,本地DNS地址,查询时间,返回消息包大小。
;; Query time: 6 msec
;; SERVER: 2400:2410:8da2:5500:1111:1111:1111:1111#53(2400:2410:8da2:5500:1111:1111:1111:1111)
;; WHEN: Sat Aug 21 01:16:05 JST 2021
;; MSG SIZE  rcvd: 586

azureuser@prod-vm-ranking:~/AmazonRanking$ ping github.com
ping: github.com: Temporary failure in name resolution
azureuser@prod-vm-ranking:~/AmazonRanking$

dig github.com @114.114.114.114

这个命令可以指定DNS服务器

cat /etc/resolv.conf ⇒ nameserver 114.114.114.114

如果通过上面dig命令没有指定DNS服务器成功的话,可以直接 在/etc/resolv.conf 文件中追加DNS服务器地址,指定好DNS服务器地址之后再重新操作git.

azureuser@prod-vm-ranking:~/AmazonRanking$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
nameserver 114.114.114.114
options edns0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误通常是由于连接到GitHub的SSH端口(端口22)被拒绝或超引起的。有几种可能的解决方法: 1. 参考中的解决方案,可以尝试在SSH配置文件中更改GitHub的主机名为ssh.github.com,并将端口设置为443。这样可以使用git pull命令来代码。 2. 参考中的解决方法,可以尝试使用HTTP连接而不是SSH连接。通过修改.git/config文件中的URL,将其改为使用https://github.com/username/repo.git。 3. 参考中的解决方案,可以尝试在SSH配置文件中添加一些内容,包括将GitHub的主机名设置为ssh.github.com,并将端口设置为443。 请注意,端口22被封锁或超可能是因为网络配置或防火墙设置。如果上述解决方法均无效,建议与网络管理员或GitHub支持团队联系,以获得更多帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote reposi...](https://blog.csdn.net/weixin_41697143/article/details/129012461)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [解决git报错:ssh:connect to host github.com port 22: Connection timed out](https://blog.csdn.net/yjxkq99/article/details/128927038)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值