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取消掉。

相关推荐
今夕资源网31 分钟前
一只鹈鹕骑着单车闯海岛:开源 3D 网页游戏《鹈鹕骑车》体验与部署教程 github开源
开源·github·ai智能测试题·ai智能测试
阿明62 小时前
Linux进程【Linux】
linux·运维·服务器
Android系统攻城狮2 小时前
Linux Gstreamer深度解析之gst_audio_resampler_update调用流程与实战(三十)
linux·运维·服务器·gstreamer音视频·音视频进阶
沙蒿同学2 小时前
我把架构约定编译成了会变红的测试:Wails v2 + Go + Vue3 桌面脚手架实战
前端·后端·github
微信ipad协议开发2 小时前
微信视频号自动化:内容发布与互动的 API 实现
运维·微信
落魄大学生之流水线上谋生计3 小时前
幻境相机 Mirage Camera
github
wangruofeng3 小时前
从一个 10 万星 AI Agent 项目里,能学到什么真正的软件工程
github·agent·ai编程
子林super3 小时前
复杂JSON Schema结构与输出校验
github
子林super3 小时前
结构化输出解析失败处理策略
github
怕浪猫4 小时前
拆解 Google《AI Agent Handbook》:企业级 Agent 的六层架构与产品矩阵
面试·github·agent