Quick fix
# ① Layer diagnosis (30 seconds, decisive)
curl -s -o /dev/null -w "%{http_code}\n" --max-time 10 https://github.com/ # 200/301 = network OK, problem is config/credentials
GIT_CONFIG_GLOBAL=/dev/null git ls-remote https://github.com/octocat/Hello-World.git # refs listed = config/credentials confirmed
# ② Network layer (unstable direct link): gh-proxy prefix, keep anonymous HTTPS
git clone https://gh-proxy.com/https://github.com/<owner>/<repo>.git
# or codeload tarball: curl -sL https://gh-proxy.com/https://codeload.github.com/<owner>/<repo>/tar.gz/refs/tags/<tag> | tar xz
# ③ Config/credentials (when ② doesn't apply): drop rewrite rules + stale proxy + re-auth gh
git config --global --unset-all "url.git@github.com:.insteadof"
git config --global --unset http.proxy && git config --global --unset https.proxy
gh auth logout && gh auth login
Rerun the original command after ② or ③. If gh-proxy is slower/fails, drop it and keep plain anonymous HTTPS (mirrors have a lifespan; probe with curl -sI first).
What you will run into
Every GitHub-dependent flow is unstable on direct connections from China: git clone of a large repo hangs at "Cloning repository" then resets; plugin/skill CLI installs report port 443 unreachable; marketplace clones fail with SSH authentication errors;
Release assets (deb/AppImage) keep dropping mid-download.
The errors look unrelated, but there are only three layers: network (unstable direct link), config (git rewrite rules / dead proxy), credentials (SSH key / gh token state). Diagnose by layer first — don't try random fixes against the error text.
Why this happens
| Layer | Root cause | Typical symptom |
|---|---|---|
| Network | Unstable direct link from China; Release assets actually live on objects.githubusercontent.com, an even worse path | Connection reset by peer, port 443 unreachable, interrupted downloads, stuck at Cloning repository |
| Config | Old tutorials left url.git@github.com:.insteadof=https://github.com/, rewriting all HTTPS to SSH; or a stale http.proxy remains | Public repos also report permission errors; every clone resets |
| Credentials | Invalid/missing SSH key, gh credential helper injecting a dead token, suspended account | SSH authentication failed, Permission denied (publickey), Your account is suspended |
Key insight: public repos are reachable anonymously over HTTPS — no credentials needed. If a public repo reports a "permission" error, suspect config and credentials first, not the network.
The three layers are three independent chains: the network layer is physical reachability of TCP/TLS to github.com and objects.githubusercontent.com — when domestic egress is unstable, connections get reset at the transport layer, unrelated to your command;
the config layer is "addressing rewrites" — insteadOf rewrites HTTPS to SSH and a leftover http.proxy points requests at a dead proxy, applied before any remote access;
the credential layer is "authentication state" — SSH keys, gh tokens, and account status decide whether non-public access is accepted.
The layers are serial: reachability first (network), then addressing per config, then credential auth — which fixes the diagnostic order from the bottom up: curl first to test the network, then insteadOf/proxy, then credentials.
When a public repo reports a "permission error", the network layer is already ruled out (you must be connected to reach authentication), so the problem can only be in the config or credential layer.
Step by step
1. Diagnose by layer — Required (30s, decides which path)
curl -s -o /dev/null -w "%{http_code}\n" --max-time 10 https://github.com/
- Timeout /
000→ network layer, go to step 2; 200/301→ network is up, continue:
GIT_CONFIG_GLOBAL=/dev/null git ls-remote https://github.com/octocat/Hello-World.git
- Refs listed → config/credentials confirmed, go to step 4;
- Also fails → the network layer throttles/drops git traffic, go to step 2.
2. Network layer: switch channels — Per diagnosis (network layer hit only)
Three channels by availability (market-probed 2026-08-28~30):
# a) gh-proxy prefix (13.5MB Release asset in seconds, tested)
curl -L -o pkg.deb "https://gh-proxy.com/https://github.com/<owner>/<repo>/releases/download/<tag>/<asset>"
# b) codeload tarball (544K / 2.1s stable, tested)
curl -sL https://codeload.github.com/<owner>/<repo>/tar.gz/refs/tags/<tag> | tar xz
# c) explicit proxy (when you have one)
git config --global http.https://github.com.proxy http://127.0.0.1:<port>
tarball downloads failing → switch to a shallow clone (git clone --depth 1); clones failing → switch to tarball. Swapping often bypasses a bad path. Off-peak retries and switching networks (mobile hotspot often works) also help.
SSH over 443 (official channel: way out when SSH itself is blocked)
If port 22 is unreachable but your SSH key is fine, GitHub officially supports SSH over port 443 (the HTTPS port) — most firewalls allow 443 while blocking 22.
# 1) Probe the 443 channel (the hostname is ssh.github.com, NOT github.com)
ssh -T -p 443 git@ssh.github.com
# Success output: Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
# 2) One-off use: clone via this address directly
git clone ssh://git@ssh.github.com:443/<owner>/<repo>.git
# 3) Permanent: write ~/.ssh/config
Host github.com
Hostname ssh.github.com
Port 443
User git
The first connection warns The authenticity of host '[ssh.github.com]:443 ...' can't be established — that's the normal known_hosts warning for a new hostname; answer yes only after matching the fingerprint against GitHub's published ED25519 fingerprints.
Two caveats: GitHub Enterprise Server does not support this channel; an explicit proxy may interfere with the 443 channel (with a proxy, prefer the gh-proxy approach above).
3. Network layer: install scenarios — use paths that don't depend on GitHub — Per scenario (install flows)
- Just want the tool:
pip install <pkg>(Tsinghua mirror-i https://pypi.tuna.tsinghua.edu.cn/simple) — no need to clone source; - Skills/plugins: unpack the tarball and copy into place (e.g.
cp -r agent-skills-0.6.7/skills ~/.claude/skills/); - Judge success by the artifact (directories/files in place), not the exit code (some CLIs return 0 on failure).
4. Config layer: check rewrite rules and stale proxy — Per diagnosis (config layer hit only)
git config --global --get-regexp 'url\..*\.insteadof' # url.git@github.com:.insteadof = culprit
git config --global --list | grep -i proxy # leftover proxy check
git config --global --unset-all "url.git@github.com:.insteadof"
git config --global --unset http.proxy
git config --global --unset https.proxy
5. Credentials: SSH and the gh credential helper — Per diagnosis (credentials hit only)
git ls-remote git@github.com:<owner>/<repo> # Permission denied (publickey) = SSH-layer problem
git config --global url."https://github.com/".insteadOf "git@github.com:" # force HTTPS (public repos are anonymous)
gh auth status # credential helper state
gh auth logout && gh auth login # re-authorize
6. Verify downloads after fetching — Required (finish)
du -h pkg.deb # compare with the asset page size; much smaller = partial, re-download
dpkg-deb -I pkg.deb >/dev/null && echo DEB-OK # readable structure = complete (deb)
Variant quick reference (8 same-root entries merged)
| Variant (original entry) | Error signature | Scenario | Root cause | Fix | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Clone reset/hang (agent-skills-1 / deepcode-2) | fatal: unable to access ... Connection reset by peer / timeout | Official CLI install, source clone | Unstable direct link, big repos dropped mid-transfer | gh-proxy codeload tarball; pip install instead | ||||||
| Port 443 unreachable (superpowers-1) | Failed to connect to github.com port 443 | Plugin /plugin install | Direct 443 blocked | codeload tarball install; explicit proxy | ||||||
| SSH auth failed (claude-mem-1) | SSH authentication failed / Permission denied (publickey) | Marketplace/plugin clone | CLI defaults to SSH, no valid key | Force HTTPS insteadOf + optional gh-proxy | ||||||
| Public repo permission error (github-clone-fail) | Your account is suspended / Please make sure you have the correct access rights and the repository exists | Network up but every clone fails | HTTPS→SSH global rewrite + account/credential issue | Anonymous HTTPS probe + --unset-all rewrite; gh re-auth | ||||||
| Release asset download drops (cc-switch-2) | TLS disconnect / interrupted download | deb/AppImage downloads | Assets on objects.githubusercontent.com are unstable | gh-proxy prefix + size check | ||||||
| zip/tarball timeout (superpowers-2) | Download timeout/interrupted | Skill/plugin zip downloads | codeload/raw paths unstable | Swap channels (tarball ↔ shallow clone); mirror zip + offline unpack | ||||||
| Stale local proxy (deepcode-2 side note) | Clone reset with a dead proxy configured | Any clone | http.proxy left pointing at a dead proxy | --unset the proxy | ||||||
| Proxy up but writes fail (cli#6689 external report) | unable to push data to server behind socks5 proxy | Proxy present but gh push/upload fails | socks5 proxy incompatible with gh write path | Switch to an http proxy or direct for gh; success = push works (not reproduced locally) | Stale local proxy (deepcode-2 side note) | Clone reset with a dead proxy configured | Any clone | http.proxy left pointing at a dead proxy | --unset the proxy | |
| Tool runtime depends on GitHub (code-review-graph-4) | Build/update hangs on GitHub access | Tool scenarios needing GitHub | Few GitHub deps in the tool | Core flow offline; pip via Tsinghua mirror; gh-proxy |
How to confirm it works
- Network layer: the original command (clone/download/install) completes with no
reset by peer/Timed out; downloads match the asset page size. - Config layer:
GIT_CONFIG_GLOBAL=/dev/null git ls-remote https://github.com/octocat/Hello-World.gitlists refs; rewrite rules and stale proxy removed. - Credentials: public repos clone over anonymous HTTPS; SSH scenarios no longer report
Permission denied; when port 22 is blocked,ssh -T -p 443 git@ssh.github.comauthenticates successfully.- Credentials: public repos clone over anonymous HTTPS; SSH scenarios no longer reportPermission denied. - Installs: judge by the artifact in place, not the exit code.
Other environments
| Environment | Notes |
|---|---|
| Direct link from China | Clone/download instability is the norm; gh-proxy / codeload / off-peak / network switch |
| Campus/home broadband | Worst at evening peak; off-peak or proxy |
| Stable proxy | Direct works; gh-proxy is a fallback; clean up stale proxy leftovers |
| Windows/macOS | Same layers; tarball flow identical, paths follow each platform |
| Fully offline | Clone/download unavailable; local tool core flows still work |
Symptom
git clonehangs at Cloning repository thenConnection reset by peer/ timeout;Failed to connect to github.com port 443;SSH authentication failed/Permission denied (publickey);- Public repos also report
Please make sure you have the correct access rights and the repository exists; - Release / zip / tarball downloads keep dropping, TLS interruptions;
- Some CLIs return exit code 0 on failure (trap).
Cause
The direct link to GitHub from China is unstable (Release assets additionally go through objects.githubusercontent.com, a worse path); HTTPS→SSH global rewrite rules and stale proxies from old tutorials amplify it; abnormal SSH key / gh credentials / account state blocks even public repos.
Solution
- Diagnose by layer:
curl https://github.com/+GIT_CONFIG_GLOBAL=/dev/null git ls-remoteto separate network/config/credentials; - Network layer channel swap: gh-proxy prefix, codeload tarball, shallow clone, explicit proxy, off-peak/network switch; when SSH itself is blocked, use the official 443 channel (ssh.github.com);2. Network layer channel swap: gh-proxy prefix, codeload tarball, shallow clone, explicit proxy, off-peak/network switch;
- Install scenarios use GitHub-free paths: pip with Tsinghua mirror, tarball manual copy; judge by artifact not exit code;
- Config layer: remove rewrite rules and stale proxy; credentials: force HTTPS / re-auth gh;
- Verify downloads by size/structure.
Verification Evidence
- github-clone-fail (tested 2026-08-29):
GIT_CONFIG_GLOBAL=/dev/null git ls-remote https://github.com/octocat/Hello-World.gitlists all refs anonymously; after--unset-all url.git@github.com:.insteadof, public clone succeeds (local repro log 2026-08-29). - agent-skills-1 (tested 2026-08-28): CLI clone reset (
Recv failure: Connection reset by peer); gh-proxy codeload tarball 277KB in seconds; all 24 skill dirs in place. - claude-mem-1 (tested 2026-08-28): SSH auth failed → force HTTPS
insteadOf→SSH not configured, cloning via HTTPS+ marketplace added. - superpowers-1/2 (tested 2026-08-28): codeload tarball 544K / 2.1s stable; gh-proxy 7.8s; raw endpoint probe timed out, avoided.
- cc-switch-2 (tested 2026-08-28): gh-proxy downloaded 13.5MB in seconds, deb structure OK exit=0; direct assets dropped.
- deepcode-2 / code-review-graph-4: installs via PyPI Tsinghua mirror succeeded; direct-link risk noted in connectivity records.
- Not tested: mirror/proxy lifespan (may die or slow down — probe first); full enterprise network environments (proxy allowlists).
Related canonicals
Read as same root (unstable egress at the network layer, mirror family):
- pip install timeout/slow (same network layer, PyPI mirrors)
- npm install slow/hang (same network layer, npm mirrors)
- Go module fetch slow/timeout (same network layer, Go proxy config)
- docker pull fails/mirror (same network layer)
- Only one specific website won't open (layer diagnosis) (same layering idea: locate the network layer with curl first)
Similar errors but different root cause: TLS/certificate issues.
References
- GitHub Docs: Using SSH over the HTTPS port — <https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port>
Applicable tools (1)
This problem is linked from the tool pages below — reachable from either side.
gitBundled solutions (combos)
This problem is part of the following verified bundles.
Source & evidence
← Coding Agents & Terminal domain | Problem Catalog Experience | Facing another issue? Go to the Helpdesk