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

相关推荐
掘金安东尼24 分钟前
前端周刊第421期(2025年7月1日–7月6日)
前端·面试·github
Charlene Fung1 小时前
vs code远程自动登录服务器,无需手动输入密码的终极方案(windows版)
运维·服务器·vscode·ssh
碣石潇湘无限路1 小时前
【部署与总结】从本地运行到公网服务器的全过程
运维·服务器
linux修理工1 小时前
ipmitool 使用简介(ipmitool sel list & ipmitool sensor list)
运维·服务器
XM-54581 小时前
2025微信小程序wxapkg解包全攻略
linux·运维·小程序
朗晴2 小时前
文本编辑器VIM的使用方法!
linux·运维·服务器
梁bk5 小时前
[Nginx]反向代理和负载均衡
运维·nginx·负载均衡
Leinwin9 小时前
微软开源GitHub Copilot Chat,AI编程领域迎新突破
microsoft·github·copilot
(:满天星:)11 小时前
第31篇:块设备与字符设备管理深度解析(基于OpenEuler 24.03)
linux·运维·服务器·网络·centos