55 lines
2.7 KiB
Markdown
55 lines
2.7 KiB
Markdown
---
|
||
title: "Git Push 连接重置问题修复"
|
||
type: source
|
||
tags: [github, git, proxy, socks5, network]
|
||
date: 2025-03-16
|
||
---
|
||
|
||
## Source File
|
||
- [[raw/Home Office/Git Push 连接重置问题修复.md]]
|
||
|
||
## Summary
|
||
- 核心主题:GitHub Push 报 `Recv failure: Connection was reset` 的修复方案
|
||
- 问题域:国内访问 GitHub 时 TCP 连接被 GFW 阻断,间歇性 TLS 握手失败
|
||
- 方法/机制:分别为 Git 配置 HTTP/SOCKS5 代理,或切换为 SSH 协议并配置代理
|
||
- 结论/价值:国内环境 Git 操作必须走本地代理,SOCKS5 速度通常优于 HTTP 代理
|
||
|
||
## Key Claims
|
||
- `Connection was reset` 是 TCP 层面中断,非权限问题;GFW 检测到 GitHub 域名后发送 TCP RST 包阻断连接
|
||
- 间歇性原因是 GitHub CDN 多 IP 部分被封锁
|
||
- HTTP 代理命令:`git config --global http.proxy http://127.0.0.1:10809`
|
||
- SOCKS5 代理命令:`git config --global http.proxy socks5://127.0.0.1:10808`
|
||
- SSH 协议切换:`git remote set-url origin git@github.com:username/repo.git`
|
||
- Linux/Mac SSH 走代理:`ProxyCommand nc -X 5 -x 127.0.0.1:10808 %h %p`
|
||
- Windows Git SSH 走代理:`ProxyCommand connect -S 127.0.0.1:10808 %h %p`
|
||
- 取消代理:`git config --global --unset http.proxy && git config --global --unset https.proxy`
|
||
|
||
## Key Quotes
|
||
> "Recv failure: Connection was reset(连接重置)并不是账号权限验证失败,而是 TCP 连接层面的中断" — 诊断关键:区分网络层 vs 应用层错误
|
||
|
||
## Key Concepts
|
||
- [[TCP RST 攻击]]:GFW 通过发送 TCP Reset 包阻断连接,非包过滤
|
||
- [[Git HTTP/SOCKS5 代理]]:通过 `http.proxy` / `https.proxy` 全局配置让 Git 流量走本地代理
|
||
- [[Git SSH 协议切换]]:将远程地址从 HTTPS 改为 SSH,规避 443 端口干扰
|
||
- [[SSH ProxyCommand]]:通过 `connect`(Windows)或 `nc`(Linux/Mac)让 SSH 走 SOCKS5 代理
|
||
- [[GFW 封锁特征]]:GitHub 域名被 DPI 检测后触发 TCP RST,CDN 节点部分被封导致间歇性
|
||
|
||
## Key Entities
|
||
- [[GitHub]]:全球最大代码托管平台,国内访问受 GFW 干扰
|
||
- [[V2RayN]]:本地 SOCKS5/HTTP 代理工具,监听 10808/10809 端口
|
||
- [[Clash]]:代理客户端,同样支持 SOCKS5 和 HTTP 出局
|
||
|
||
## Connections
|
||
- [[Git HTTP/SOCKS5 代理]] ← solves ← [[TCP RST 攻击]]
|
||
- [[Git SSH 协议切换]] ← alternative_to ← [[Git HTTP/SOCKS5 代理]]
|
||
- [[V2RayN]] ← provides ← [[SOCKS5 代理]]
|
||
- [[GitHub]] ← blocked_by ← [[GFW 封锁特征]]
|
||
|
||
## Contradictions
|
||
- 与其他 Git 代理方案(如 `gh proxy`、VPN 全局模式)相比:本文方法仅影响 Git 命令,不干扰终端其他网络请求
|
||
|
||
## Metadata
|
||
- 作者:shenwei
|
||
- 创建时间:2025-03-16
|
||
- 原始标签:[github, proxy, push, socks5]
|