加载中...

git ssh: connect to host ssh.github.com port 443: Connection refused问题解决

博客 2025.04.30 21:18 18

执行git命令的时候提示:

ssh: connect to host ssh.github.com port 443: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

执行ssh -T -P 443 git@ssh.github.com时提示:

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

显示更多日志为:

OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2
debug1: Reading configuration data C:\\Users\\aft/.ssh/config
debug1: Connecting to ssh.github.com [127.0.0.1] port 22.
debug1: connect to address 127.0.0.1 port 22: Connection refused
ssh: connect to host ssh.github.com port 22: Connection refused

可以看到ssh.github.com的ip地址变成了127.0.0.1

这些都是dns的问题
打开github.com dnsCheck
打开ssh.github.com dnsCheck

6d2b0727f10a90985ef61c5e5cab540.jpg

把相应的ip配置到hosts文件

20.205.243.166 github.com
20.205.243.160 ssh.github.com

执行ipconfig /flushdns刷新dns就能连接成功