BUG日志:使用热点或免费加速器时git链接github出现端口22拒绝访问的解决方法

问题描述

  • 现象git 连接 GitHub 时,报错 Connection refused on port 22
  • 触发条件
    1. 使用移动热点或免费加速器时必现。
    2. 使用正常 Wi-Fi 时不出现。

解决步骤

  1. 临时切换为 HTTPS 协议(绕过 22 端口):

    bash 复制代码
    git remote set-url origin https://github.com/username/repo.git
  2. 强制 SSH 走 443 端口(GitHub 支持):

    • 修改 ~/.ssh/config

      bash 复制代码
      Host github.com
        Hostname ssh.github.com
        Port 443
        User git
    • 测试连接:

      bash 复制代码
      ssh -T git@github.com
  3. 检查代理冲突

    • 若使用加速器,关闭或重置 Git 代理配置:

      bash 复制代码
      git config --global --unset http.proxy
      git config --global --unset https.proxy

验证结果

  • ✅ HTTPS 协议可正常 git push/pull
  • ✅ SSH over 443 端口后,连接成功。

补充说明

  • 关联场景:移动网络或公共代理可能屏蔽 22 端口。
  • 快速修复优先级
    1. 优先使用 HTTPS。
    2. 长期方案:配置 SSH over 443。
相关推荐
逛逛GitHub8 小时前
这个爆红的 GitHub 项目让 token 直接省 60–95%。
github
iccb10139 小时前
5年,一个程序员是如何把私有化在线客服系统做到第一名的
前端·后端·github
蝎子莱莱爱打怪10 小时前
AI Agent 相关知识扫盲:16 个概念+11张图+38个开源项目推荐
人工智能·github·agent
用户3177230703612 小时前
Pydub:用 Python 处理音频,不写废话
github
深海鱼在掘金12 小时前
Git 完全指南 —— 第1章:Git 概览与版本控制演进
git
张居邪13 小时前
GitHub Actions + 阿里云 OSS:OIDC 免密同步构建产物
后端·github
张居斜1 天前
GitHub Actions + 阿里云 OSS:OIDC 免密同步构建产物
github·oss·llm-wiki
用户3228360084471 天前
python-rapidjson:用 C++ 速度处理 JSON 的 Python 库
github
逛逛GitHub1 天前
4 个比较实用的 GitHub 开源项目,浅浅的收藏一波。
github
Hommy881 天前
【剪映小助手】添加贴纸接口(Add Sticker)
后端·github·剪映小助手·视频剪辑自动化·剪映api