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

相关推荐
tritone5 小时前
我在阿贝云免费服务器上搭建RustDesk自建服务器(Self-Hosting)的真实体验【推荐】
运维·服务器
2301_800050995 小时前
DNS 服务器
linux·运维·笔记
慌糖5 小时前
自动化接口框架搭建分享-pytest第二部分
运维·自动化·pytest
Lin_Aries_04215 小时前
容器化简单的 Java 应用程序
java·linux·运维·开发语言·docker·容器·rpc
岁岁种桃花儿6 小时前
详解 Kubernetes 命令:kubectl exec -it nginx -- bash 及实战场景
运维·nginx·kubernetes
小牛马爱写博客6 小时前
DNS 服务器与 DHCP 服务器详解及配置指南
linux·运维·服务器·dns·dhcp
维尔切6 小时前
HAProxy 负载均衡器
linux·运维·数据库·负载均衡
VueVirtuoso6 小时前
前后端部署 + Nginx 配置 + Cloudflare 全攻略(通俗易懂版)
运维·nginx
QQ12958455046 小时前
服务器跨域问题CORS的解决
运维·服务器
小白银子6 小时前
零基础从头教学Linux(Day 42)
linux·运维·服务器·网络·nginx