错误内容
git 拉取gitihub 代码报错
kex_exchange_identification: Connection closed by remote host
Connection closed by 20.205.243.166 port 22
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
ip 可以ping通 windows 和mac 拉取均报错 无论是否开代理都会有这个问题 网上分析原因 是防火墙 或者代理软件的问题。找到官方文档 docs.github.com/en/authenti… 有时,防火墙完全拒绝允许 SSH 连接。如果使用带有凭据缓存的 HTTPS 克隆不是一种选择,您可以尝试通过 HTTPS 端口建立的 SSH 连接进行克隆。大多数防火墙规则应该允许这样做,但代理服务器可能会干扰。
解决方案:
启用通过 HTTPS 的 SSH 连接
~/.ssh/config
Host github.com
Hostname ssh.github.com
Port 443
User git
第一次在切换到 443 端口后与 GitHub 交互,您可能会收到一条警告消息,提示在 known_hosts
中找不到主机,或者它以另一个名称被发现
# The authenticity of host '[ssh.github.com]:443 ([140.82.112.36]:443)' can't be established.
# ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
# This host key is known by the following other names/addresses:
# ~/.ssh/known_hosts:32: github.com
# Are you sure you want to continue connecting (yes/no/[fingerprint])?
输入 yes 回答是安全的