github push:ssh: connect to host github.com port 22

原来的github的项目使用的是ssh来进行推送,今天再尝试推送发现push超时:

stackoverflow的帖子说:

How to fix "ssh: connect to host github.com port 22: Connection timed out" for git push/pull/... commands?

也就是找到.ssh文件夹然后在该文件夹下面添加一个config文件,文件内容为:

bash 复制代码
Host github.com
 Hostname ssh.github.com
 Port 443

重新run了一下:

bash 复制代码
ssh -T git@github.com

依旧超时:

bash 复制代码
ssh: connect to host github.com port 22: Connection timed out

尝试了另一个帖子:

输入

bash 复制代码
git config --local -e

修改了url为https协议。

重新push

fatal: unable to access 'https://github.com//xxx.git/': Failed to connect to github.com port 443 after 21100 ms: Timed out

443端口又超时了,参考了一篇知乎的文章最终解决了:

解决 Github port 443 : Timed out

修改网络配置:

bash 复制代码
git config --global http.proxy http://127.0.0.1:7890 
git config --global https.proxy http://127.0.0.1:7890

其他相关配置:

bash 复制代码
# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy

# 查看代理
git config --global --get http.proxy
git config --global --get https.proxy

推送github需要设置网络代理,如果推送gitee不需要了可以使用unset取消掉。

相关推荐
浪游东戴河21 小时前
网线简介及分类
运维·服务器·网络
国冶机电安装21 小时前
自动化工程:推动工业智能化与效率提升的核心技术
运维·自动化
Renhao-Wan21 小时前
基于 GitHub Actions 构建标准化 CI/CD 流水线——从手动部署到全自动化交付
ci/cd·自动化·github
一殊酒21 小时前
【Docker】快速入门指南
运维·docker·容器
irpywp1 天前
Skales:你的本地AI特工
github
徒 花1 天前
ubuntu远程连接ssh及VSCode配置远程ssh连接ubuntu
vscode·ubuntu·ssh
十五年专注C++开发1 天前
Linux 下用 VS Code 高效调试
linux·运维·服务器·c++·vscode
闲猫1 天前
Java ApacheSSHD实现SSH代理
运维·服务器·ssh
蓝队云计算1 天前
怎么用服务器养龙虾OpenClaw?云上OpenClaw快速部署指南(小白极速版)
运维·服务器·人工智能·云服务器·openclaw
Mr_Chenph1 天前
备份Docker
运维·docker·容器