时光匆匆,转眼间到了2024年的最后一天,似乎2024还没有写习惯,又不得不写2025。 这是切换回 github 的第一篇文章,在此恭祝大家2025元旦快乐,学业有成!
问题描述
今天遇到了无法使用git拉取仓库的问题, 同时百度获知有好多人遇到了同样的问题,其的原因是"DNS 污染"。 同样也有人遇到了下面的错误:
1
2
3
4
5
6
| $ git pull
ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
|
同样,在使用ssh克隆仓库时也会遇到相同的问题,表现为:
1
2
3
4
5
6
7
8
| $ ssh -vT git@github.com
OpenSSH_9.0p1, OpenSSL 1.1.1o 3 May 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [::1] port 22.
debug1: connect to address ::1 port 22: Connection refused
debug1: Connecting to github.com [127.0.0.1] port 22.
debug1: connect to address 127.0.0.1 port 22: Connection refused
ssh: connect to host github.com port 22: Connection refused
|
解决方法
在/etc/hosts文件中,增加一条github.com的域名映射:
1
| 140.82.113.4 github.com
|
参考文章