kex_exchange_identification: Connection closed by remote hostConnection closed by ::1 port 22
缘起
- 拉代码仓库出错,还挺常见
https 错误原因:
fatal: unable to access ‘https://github.com/jing-zhi/go-sword-admin.git/’: SSL certificate problem: unable to get local issuer certificate
ssh 错误原因:
kex_exchange_identification: Connection closed by remote host
Connection closed by ::1 port 22
fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.
jingz@jing-zhi- MINGW64 /d/sanyue_project/sanyue-框架
$ git clone https://github.com/jing-zhi/go-sword-admin.git
Cloning into 'go-sword-admin'...
fatal: unable to access 'https://github.com/jing-zhi/go-sword-admin.git/': SSL certificate problem: unable to get local issuer certificate
jingz@jing-zhi- MINGW64 /d/sanyue_project/sanyue-框架
$ git clone git@github.com:jing-zhi/go-sword-admin.git
Cloning into 'go-sword-admin'...
kex_exchange_identification: Connection closed by remote host
Connection closed by ::1 port 22
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
推测
推测原因之一:github的邮箱地址和git global的email不一样
git config --global user.email "jingzhi736728@163.com" // 设置成和我在github账号一样的邮箱
$ ssh-keygen –t rsa –C "jingzhi736728@163.com" // 重新生成key
结果——失败了,依旧报同样错
推测其他原因等…
$ ssh -T git@github.com
检查github公钥配置情况出错。
根据报错原因,推测可能是22端口把他关闭了,先检查一下22端口号是否开启
netstat -na
如图是开启的
真正原因
之前国内对github完全封死,造成DNS域名解析错误,即便翻外网进去也不能直接拉代码了。需要一点配置
然而我有个好兄弟给我解决了
- C:\Windows\System32\drivers\etc
- 在hosts中添加github的ip地址对应:140.82.112.3 github.com