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。
相关推荐
子兮曰41 分钟前
async/await高级模式:async迭代器、错误边界与并发控制
前端·javascript·github
Selicens9 小时前
git批量删除本地多余分支
前端·git·后端
崔庆才丨静觅13 小时前
Claude Code GitHub Actions 使用教程
github·api·claude
闲云一鹤1 天前
Git LFS 扫盲教程 - 你不会还在用 Git 管理大文件吧?
前端·git·前端工程化
砖厂小工1 天前
用 GLM + OpenClaw 打造你的 AI PR Review Agent — 让龙虾帮你审代码
android·github
程序员鱼皮1 天前
又一个新项目完结,我要出海了!
ai·github·开源项目
徐小夕2 天前
pxcharts-vue:一款专为 Vue3 打造的开源多维表格解决方案
前端·vue.js·github
Moment2 天前
想要长期陪伴你的助理?先从部署一个 OpenClaw 开始 😍😍😍
前端·后端·github