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。
相关推荐
全栈陈序员1 小时前
【Git】从入门到精通(六)—— git commit:提交到版本库
大数据·git·elasticsearch
miofly1 小时前
GitHub 日榜趋势速报 | 2026-11-04
开源·github
钱栈up9 小时前
GitHub 热榜上手|Orca:让多个编码 Agent 并排跑
github
灼行11 小时前
Autosar SecOC 需求场景BUG(需求不一致性)【草稿】
bug
wflynn14 小时前
GitHub 日榜趋势速报 | 2026-11-02
开源·github
徐小夕15 小时前
深度剖析 30k star 的编码 Agent DeepSeek-Reasonix:长会话 Token 成本直降 80%
前端·vue.js·github
Iron_15 小时前
多平台内容分发的适配器
github
u13013015 小时前
GitHub 热榜项目:日榜(2026-11-02)
人工智能·github
Sakura_j_h_16 小时前
GitHub Actions 打包 Windows exe:中文编码与产物上传
windows·ci/cd·打包发布·github·pyinstaller·github actions