ssh: connect to host ssh.github.com port 443: Connection refused

前段时间gitee将所有开源的仓库改成需要审核才能重新开源这个事在国内程序员圈子内还引起来不小的动静,不过对我来说倒没什么影响,开源的项目基本都放在GitHub,gitee就挂了几个私有仓库。

尽管GitHub访问不方便,但依然阻挡不了大家对GitHub的热爱,毕竟这里是全球程序员的智慧结晶。

对于GitHub经常被墙的事,我发现有时候即时用science上网还是会出现 Connection refused 的错误,特别是在push代码的时候会出现,这就很影响写代码的心情。

>git push origin main

ssh: connect to host ssh.github.com port 443: Connection refused

fatal: Could not readfrom remote repository.

然后浏览器访问 GitHub.com 网站又是正常的,我估计是域名解析被污染了。于是我想到的一个办法是,先查看ssh.github.com 这个域名对应的ip是哪个?

这个可以直接在 https://ipaddress.com/website/ssh.github.com 查到该ip。

 

查出来ssh.github.com的IP是 140.82.114.36。

知道ip后,接下来测试下ssh是否可以连上改ip

ssh -T -p 443 git@140.82.114.36

The authenticity of host '[140.82.114.36]:443 ([140.82.114.36]:443)'can 't be established.

ECDSA key fingerprint is SHA256:p2QA

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Warning: Permanently added ' [140.82.114.36]:443 ' (ECDSA) to the list of known hosts.

Hi lzjun567 You' ve successfully authenticated, but GitHub does not provide shell access.

如果看到最后一行 Hi xxxx 就说明没问题。

这时候,找到当前用户目录下的.ssh/config 文件,如果没有就自己建一个。只要将Hostname ssh.github.com换成ip地址140.82.114.36即可

Host github.com

Hostname 140.82.114.36

Port 443

最后重新push代码,大功告成

>git push origin main

Enumerating objects: 40, done.

Counting objects: 100% (40/40), done.

Delta compression using up to 4 threads

Compressing objects: 100% (28/28), done.

Writing objects: 100% (28/28), 4.15 KiB | 849.00 KiB/s, done.

Total 28 (delta 22), reused 0 (delta 0), pack-reused 0

赶紧用起来吧

posted on 2022-05-25 22:46  卡农2014  阅读(730)  评论(0编辑  收藏  举报

导航