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

相关推荐
江湖有缘1 小时前
Docker部署HamsterBase Tasks任务管理工具
运维·docker·容器
huangdong_2 小时前
1688商品图片批量下载与SKU图自动分类技术完整实现方案
运维·服务器
yyuuuzz2 小时前
独立站运营的几个技术层面常见问题
大数据·运维·服务器·网络·数据库·aws
MXsoft6182 小时前
**用自动化脚本给MAC误阻断留条后路:可审计、可回滚的准入控制方案**
运维·macos·自动化
ai_coder_ai2 小时前
在自动化脚本中如何调用大语言模型?
运维·语言模型·自动化
我星期八休息2 小时前
Linux系统编程—mmap文件映射
java·linux·运维·服务器·数据库·mysql·spring
java_cj2 小时前
从kubectl源码学pprof:生产环境性能分析的实战指南
运维·云原生·容器·kubernetes
Tian_Hang3 小时前
Linux基础知识(五)
linux·运维·服务器
放下华子我只抽RuiKe53 小时前
FastAPI 全栈后端(八):部署与运维
运维·数据库·react.js·oracle·数据挖掘·前端框架·fastapi
江畔柳前堤3 小时前
github实战指南04-Actions 自动化实战
运维·自动化·github