github连接超时(不能push,不能pull)

原文转自:github连接超时(不能push,不能pull) | 夜空中最亮的星

git pull 或者git push的时候,提示:

kex_exchange_identification: Connection closed by remote host
Connection closed by 127.0.0.1 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
  1. 使用命令:ssh -T [email protected]
    1. 返回结果:Hi developer! You’ve successfully authenticated, but GitHub does not provide shell access.
    2. 表明没有问题
  2. 使用代理:
#只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

#取消代理
git config --global --unset http.https://github.com.proxy

还是同样的问题。

3. 将ssh的22端口改为使用443

在等待git pull命令超时之后报出了类似: ssh: connect to host github.com port 22: Connection timed out的错误!

原因是: ssh 阻塞了22端口!

解决方法: 修改 ssh 的配置文件

关于修改配置,存在两种解决方法:

/etc/ssh/ssh_config 中修改全局配置
在用户主目录下.ssh/中添加配置文件
这里选择的后者:

cd ~/.ssh/
vi config

# 在config中添加下面内容
Host github.com  
User git  
Hostname ssh.github.com 
PreferredAuthentications publickey  
IdentityFile ~/.ssh/id_rsa 
Port 443
即: 使用https的443端口进行访问!

猜你喜欢

转载自blog.csdn.net/glovenone/article/details/128376286