AIFeed

后量子 GitHub SSH

Translation(model translation, not the source's own text)

Post-Quantum GitHub SSH

科技圈正因为 NSA 的后量子密码学(PQC)公告以及 Matthew “🤡” Prince 那条现已删除的含糊其辞的帖子而一片哗然。但这次似乎确实有点“东西”,不像 Anthropic 本周早些时候一头撞进去的那场彻头彻尾的空欢喜。

鉴于我们的“上级”们屈尊与我们分享的细节少得令人沮丧,Filippo Valsorda 有一些值得考虑的分析和细节。去读一读。世界大概不会明天就完蛋,但尽早摆脱 Ed25519 还是值得的。

如果你和我一样,在 ~/.gitconfig 里有这么一段,那你很可能只通过 SSH 与 GitHub 的 git 服务器交互。


        [url "[email protected]:"]
    insteadOf = https://github.com/
      

这份分步指南帮助你在与 GitHub SSH 交互时遵循 Filippo 的建议。这里有两个脆弱点:密钥交换和身份认证。

脆弱性检查

如果你没看到 mlkem… 或 sntrup…,参见密钥交换。


        # key exchange check
ssh -v -o ControlPath=none -T [email protected] 2>&1 | grep "kex: algorithm"
      

如果你看到 Ed25519 密钥或小于 3072 的 RSA 密钥,参见身份认证。


        # auth check
ssh -v -o ControlPath=none -T [email protected] 2>&1 | grep "Server accepts key"
      

或者,检查你公开注册的密钥:https://github.com/$GITHUB_USERNAME.keys

修复

密钥交换

OpenSSH 10.6 和 GitHub 都不提供纯 PQC 选项(ML-KEM/FIPS 203)。截至 2026-09-22,GitHub 提供 mlkem768x25519-sha256,所以混合 PQC 方案是目前我们能做的最好选择——这与 NSA 的公告一致。

有些系统会在 /etc/ssh/crypto.conf 中强制使用可能脆弱的默认值。如果你在受管理的笔记本电脑上无法自行修改,请把以下配置放入 ~/.ssh/config。


        Host github.com
    KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512
      

没错,就是 KexAlgorithms,即“密钥交换”。

身份认证

截至 2026-12-04,GitHub 在生成新的认证密钥时仍建议使用 Ed25519。这大概不再是个好主意,而且 GitHub 不提供任何用于认证的 PQC 方案。目前我们能做的最好选择是使用 RSA-3072 或 P-384。

  • 生成新密钥 export GH_KEY="$HOME/.ssh/id_ecdsa_github" ssh-keygen -t ecdsa -b 384 -f "${GH_KEY}" # copy to clipboard on mac pbcopy < "${GH_KEY}.pub"

生成新密钥


        export GH_KEY="$HOME/.ssh/id_ecdsa_github"
ssh-keygen -t ecdsa -b 384 -f "${GH_KEY}"

# copy to clipboard on mac
pbcopy < "${GH_KEY}.pub"
      
  • 在 https://github.com/settings/keys 将你的新公钥注册为认证密钥
  • 要么把旧的 Ed25519 密钥移出 ~/.ssh,要么在 ~/.ssh/config 中为 GitHub 添加 IdentityFile 和 IdentitiesOnly 值。Host github.com KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512 IdentityFile ~/.ssh/id_ecdsa_github IdentitiesOnly yes

要么把旧的 Ed25519 密钥移出 ~/.ssh,要么在 ~/.ssh/config 中为 GitHub 添加 IdentityFile 和 IdentitiesOnly 值。


        Host github.com
    KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512
    IdentityFile ~/.ssh/id_ecdsa_github
    IdentitiesOnly yes
      

已验证提交

如果你使用 SSH 已验证提交:

  • 在 https://github.com/settings/keys 将你的新公钥注册为签名密钥
  • 在 ~/.gitconfig 中更新你的签名密钥 [user] signingkey = ~/.ssh/id_ecdsa_github.pub [gpg] format = ssh [commit] gpgsign = true

在 ~/.gitconfig 中更新你的签名密钥


        [user]
    signingkey = ~/.ssh/id_ecdsa_github.pub
[gpg]
    format = ssh
[commit]
    gpgsign = true
      

验证

你需要清理任何现有的 ControlPath 连接,并把新密钥添加到 ssh agent,新密钥才能对 git 操作生效。


        export GH_KEY="$HOME/.ssh/id_ecdsa_github"
ssh -O exit [email protected] # if you are using ControlPersist like I do
ssh-add -D                 # if you are using an agent, drop old keys
ssh-add "${GH_KEY}"        # add new key
      

文章标题:后量子 GitHub SSH

正文:


        ssh -v -o ControlPath=none -T [email protected] 2>&1 \
| tr -d '\r' \
| awk -v b="$(ssh-keygen -lf "${GH_KEY}.pub" | cut -d' ' -f1)" '
    /kex: algorithm:/ { k = $NF }
    /Server accepts key/ { t = $6 }
    END {
        ok = (k ~ /^(mlkem|sntrup)/ && ((t == "ECDSA" && b >= 384) || (t == "RSA" && b >= 3072)))
        print (ok ? "PASS" : "FAIL"), "kex=" k, "auth=" t "-" b
        exit !ok
    }'
      

… 在我这里输出的是 PASS kex=mlkem768x25519-sha256 auth=ECDSA-384。

相关标签:

站点菜单

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by Lobsters
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗