1. 配置Github SSH keys出现的问题主要集中在Windows系统上,报错信息主要是22端口和443端口的问题,原因在于未正确进行config和known_hosts的配置。
2. 本文参考了“手机电脑看过来”的搜狐技术文章:github push代码总出错,有没有招儿?_GitHub_ssh_com
配置步骤:
1. 利用Git进行SSH keys的本地生成并粘贴至Github的SSH keys,相关配置教程较多,此处不再赘述;
2. 然而在进行基于SSH的代码pull和push的时候,会报下面两个错误:
ssh: connect to host github.com port 22: Connection refused
kex_exchange_identification: Connection closed by remote host
Connection closed by 172.65.251.182 port 443
解决方案多数是对config文件进行编辑,或者关闭全局SS等,但对我来说都不见效。(PS:我在macOS上配置Github的SSH时,是不会报错的)
3. 参考 “手机电脑看过来”的技术文章,先测试Github的域名是否被poluted:
ssh -T -p 443 git@140.82.114.36
The authenticity of host '[140.82.114.36]:443 ([140.82.114.36]:443)'can 't be established.
ECDSA key fingerprint is SHA256:p2QA
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added ' [140.82.114.36]:443 ' (ECDSA) to the list of known hosts.
拿到IP后进行测试,此时会在C:\Users\lixu\.ssh文件夹下生成known_hosts文件,若出现以下字样,则代表ssh可以连上该ip:
4. 编辑config文件:
此时需要将Hostname ssh.github.com 换成ip地址140.82.114.36:
最后代码便可pull和push了!