← 返回
开发者工具 中文

Github Private Repo SSH Routing

Diagnose and manage SSH keys, host aliases, and Git remotes for GitHub private repositories in multi-repo environments. Use when deploy keys collide, a machi...
在多仓库环境中诊断并管理 GitHub 私有仓库的 SSH 密钥、主机别名和 Git 远程地址。适用于部署密钥冲突、机器……
darinrowe
开发者工具 clawhub v1.0.1 2 版本 99830.2 Key: 无需
★ 0
Stars
📥 588
下载
💾 9
安装
2
版本
#latest

概述

GitHub Deploy Key Routing

Treat GitHub private repo access as a routing problem, not just a Git problem.

Core rules

  • Use one deploy key per private repository unless a machine user is intentionally chosen.
  • Use one SSH host alias per key.
  • Point each repo remote at the correct alias explicitly.
  • Do not rely on a catch-all Host github.com when multiple deploy keys exist.
  • Verify SSH first, then Git, then push.
  • If automation is involved, fix both the live repo remote and the config/script source that writes it.

Canonical pattern

Host github.com-backup
    HostName github.com
    User git
    IdentityFile ~/.ssh/openclaw_backup_ed25519
    IdentitiesOnly yes
git remote set-url origin git@github.com-backup:OWNER/REPO.git

Use this skill when the machine has more than one private GitHub repo, more than one SSH key, or any recurring GitHub automation.

Quick triage

If you need the fastest route:

  1. Read references/symptoms.md and match the exact error.
  2. Read references/patterns.md and compare the current alias + remote layout.
  3. Read references/decision-guide.md only if the identity model itself is still undecided.
  4. Read references/openclaw-automation.md only when a script, backup flow, or config value may be rewriting the remote.

Workflow

1. Identify the repo + remote actually in use

Check the local repo path, current remotes, and whether the failing action came from:

  • an interactive repo command
  • a backup/sync script
  • a config file that stores the repo URL
  • a cron/automation job

If the repo path and the config source differ, do not treat them as the same fix.

2. Identify the key-routing layer

Read references/patterns.md for the standard alias layout.

Read references/key-storage-by-system.md when OS-specific key locations or mixed Windows/WSL/macOS behavior may matter.

Ask:

  • Which SSH alias is the repo using now?
  • Which key does that alias select?
  • Is that key actually authorized for this repo?
  • Is a broad Host github.com rule hijacking traffic?

3. Diagnose by symptom

Read references/symptoms.md and match the exact failure string before changing anything.

4. Choose the right identity model

Read references/decision-guide.md when the user is deciding between:

  • deploy key
  • personal SSH key
  • machine user

Read references/identity-model-boundaries.md when the question is really about where SSH routing ends and GitHub API authority begins — especially for PR merge automation, release creation, or fine-grained PAT vs deploy key decisions.

5. Check automation-specific drift

Read references/openclaw-automation.md when the repo is used by OpenClaw backup/restore, plugins, cron jobs, or config-driven workflows.

6. Fix in the safe order

  1. Fix or add the SSH alias.
  2. Verify with ssh -G .
  3. Test with ssh -T git@.
  4. Update the repo remote URL.
  5. Update any config/script source that still writes the old remote.
  6. Verify with git ls-remote origin.
  7. Only then push or pull.

Minimal command set

ls -la ~/.ssh
sed -n '1,200p' ~/.ssh/config
git remote -v
ssh -G <host-alias> | sed -n '1,40p'
ssh -T git@<host-alias>
git ls-remote origin

Bundled script

For a read-only audit of one local repo, run:

scripts/audit-routing.sh /path/to/repo

The script summarizes:

  • repo remotes
  • inferred SSH alias from origin
  • ~/.ssh files and permissions
  • ~/.ssh/config preview
  • ssh -G summary for the detected alias

Use the script to inspect before editing.

What to report

  • Root cause in one sentence
  • Whether the failure is local config, GitHub permission, or both
  • The minimal fix
  • Exactly what changed

版本历史

共 2 个版本

  • v1.0.1 当前
    2026-03-29 21:06 安全 安全
  • v1.0.0
    2026-03-14 03:27

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 672 📥 324,405
developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 68 📥 180,372
developer-tools

Agent Browser

matrixy
专为AI智能体优化的无头浏览器自动化CLI,支持无障碍树快照和基于引用的元素选择。
★ 427 📥 118,329