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

相关推荐
qianmoQ1 小时前
GitHub 趋势日报 (2025年07月25日)
github
墨迹的陌离2 小时前
【Linux】重生之从零开始学习运维之Mysql
linux·运维·服务器·数据库·学习·mysql
Ray Song2 小时前
Linux DNS解析1--终端通过网关或者路由器进行域名解析的原理
linux·运维·服务器·dns解析
2025年一定要上岸2 小时前
【pytest高阶】源码的走读方法及插件hook
运维·前端·python·pytest
Zero .2 小时前
macbook安装homebrew
linux·运维·服务器
患得患失9492 小时前
【GitHub Workflows 基础(一)】认识 .github/workflows/ 下的多个工作流
github
伟大的大威3 小时前
Docker 部署 Supabase并连接
运维·docker·容器
木人舟3 小时前
github copilot接入openai-compatible模型以及去除安全限制的方法
github·copilot
孙克旭_3 小时前
day062-监控告警方式与Grafana优雅展示
linux·运维·zabbix·grafana
那个指针是空的?4 小时前
动/静态库的原理及制作
linux·运维·服务器