【开启代理后使用ssh协议连接GitHub失败的解决方法: kex_exchange_identification: Connection closed by remote host Connection closed by 127.0.0.1 xxxx】

报错示例

kex_exchange_identification: Connection closed by remote host
Connection closed by 127.0.0.1 xxxx

解决方法

修改 ~/.ssh/config

参考:https://docs.github.com/en/authentication/troubleshooting-ssh

修改前

# 1
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
# 2
Host github.com-hugh
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_hugh
# 3
Host e.coding.net-260
HostName e.coding.net
User git
IdentityFile ~/.ssh/id_rsa_shield

与远端交互会报错:

kex_exchange_identification: Connection closed by remote host
Connection closed by 127.0.0.1 port 7890

修改后

# 1
Host github.com
HostName ssh.github.com
User git
Port 443
IdentityFile ~/.ssh/id_rsa
# 2
Host github.com-hugh
HostName ssh.github.com
User git
Port 443
IdentityFile ~/.ssh/id_rsa_hugh
# 3
Host e.coding.net-260
HostName e.coding.net
User git
IdentityFile ~/.ssh/id_rsa_shield

与远端交互:正常:

# adward @ 192 in ~/development/demosProj/coder-rules/coder-rules2 on git:main o [12:34:37] 
$ ssh -T git@github.com                                
Hi 13MountainsFall! You've successfully authenticated, but GitHub does not provide shell access.
(base) 
# adward @ 192 in ~/development/demosProj/coder-rules/coder-rules2 on git:main o [12:35:00] C:1
$ ssh -T git@github.com-hugh
Hi hughedward! You've successfully authenticated, but GitHub does not provide shell access.
(base) 
posted @ 2025-06-14 12:55  十三山入秋  阅读(79)  评论(0)    收藏  举报