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。
相关推荐
u13013017 小时前
GitHub 热榜项目:日榜(2026-10-12)
人工智能·github
Ken_P_##18 小时前
WordAgent
github·agent
u13013018 小时前
GitHub 热榜项目:日榜(2026-10-11)
人工智能·github
miofly19 小时前
GitHub 日榜趋势速报 | 2026-10-13
开源·github
高频因子挖掘机19 小时前
Python 批量获取股票行情后,如何用 Pandas 统一字段、索引和数据类型?
后端·github·api
高频因子挖掘机19 小时前
多股票 K 线如何用 Pandas 对齐?从收益率计算到横截面分析
后端·github·api
用户202252215061 天前
我在 DSH 做了个 AI 交付验收台:没有证据,就不算通过
github
前端市界1 天前
Pro React Admin: 统一工程底座,承载多种应用...
前端·github
zttbee1 天前
git命令
git