现象
最近pull或者push操作github仓库时,出现kex_exchange_identification: Connection closed by remote host
错误,导致无法拉取代码(使用ssh协议):
# git pull
kex_exchange_identification: Connection closed by remote host
Connection closed by 127.0.0.1 port 7897
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
原因
网上找了下,说是因为梯子禁用了22端口,导致无法通过ssh连接github
解决办法
根据github官方文档的说明,可以使用HTTPS的SSH连接来访问github,编辑文件~/.ssh/config
加入以下配置,问题即可解决:
Host github.com
Hostname ssh.github.com
Port 443
User git