后量子 GitHub SSH
Post-Quantum GitHub SSH

原始链接: https://bauer.codes/post/2026/12/post-quantum-github-ssh/

文章认为,近期 NSA 的后量子指南以及 Filippo Valsorda 的分析表明,即便没有迫在眉睫的紧急情况,现在就加固 GitHub SSH 也是明智之举。它关注通过 Git URL 重写以 SSH 方式访问 GitHub 的用户。 有两个方面很重要:密钥交换和身份验证。用户应检查 GitHub 是否协商使用 `mlkem768x25519-sha256` 或 `sntrup761x25519-sha512`;如果没有,应在 `~/.ssh/config` 中为 `github.com` 添加 `KexAlgorithms` 条目。由于 GitHub 没有纯 PQC 选项,混合 ML-KEM 是最佳可用选择。 对于身份验证,文章建议逐步弃用 Ed25519 和较弱的 RSA 密钥。生成 ECDSA P-384 密钥(或 RSA-3072),将其注册到 GitHub,并将 GitHub SSH 限制为使用该 `IdentityFile`。使用 SSH 验证提交的人还应将新密钥注册为签名密钥,并更新 `~/.gitconfig`。最后,清除现有的 SSH 控制连接,刷新 `ssh-agent` 中的密钥,并确认连接显示为混合 kex 以及 ECDSA-384 或 RSA-3072 身份验证。

讨论围绕在 GitHub 上使用后量子/混合 SSH 展开。评论者指出,GitHub 支持混合密钥交换 `mlkem768x25519-sha256`,而通过 `gh auth https` 访问 api.github.com 仍只使用 X25519/P-256;经 Cloudflare 的 GitLab HTTPS 可能会协商混合 TLS。该博客的建议——在 ML-DSA SSH 密钥可用之前,使用 SSH 进行 Git 操作,并采用范围严格受限的非 PQ 密钥——被视为针对“先窃取、后解密”威胁的合理防护。实际障碍依然存在:许多客户端缺少带有 ML-KEM 的 OpenSSH 构建,Linux 钥匙串可能不支持 PQ 密钥,导致一些人退而使用较大的 RSA 密钥。在密码学争论中,几位评论者认为混合方案至少与纯 ML-KEM 一样强,因为必须攻破两个组件才行,并指出 NSA 指南接受 X25519MLKEM768。随后有人猜测政府对适合硬件实现的算法有偏好。另一条讨论串则争论 GitHub 发布 SSH 公钥的问题:批评者称这是一种选择退出式的隐私/身份风险,而另一些人强调公钥本就应当公开,并可用于验证 GitHub 身份。
相关文章

原文
bauer.codes | Post-Quantum GitHub SSH

Menu

2026-12-04

Tech is in a tizzy over the NSA Post-Quantum Cryptography (PQC) advisory and Matthew “🤡” Prince’s now deleted vagueposting.
But there does seem to be something “there” there unlike the big fat nothing burger Anthropic blundered into literally earlier this week.

Given how frustratingly few details our betters deign to share with the rest of us, Filippo Valsorda has some analysis and details worth considering. Read it. The world probably isn’t ending tomorrow, but it’s worth getting off Ed25519 sooner rather than later.

If, like me, you have this bit in your ~/.gitconfig, you likely interact with GitHub’s git server exclusively via SSH.

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

This step-by-step guide helps you follow Filippo’s recommendations when interacting with GitHub SSH. There are two points of vulnerability here: key exchange and authentication.

vulnerability checks

If you don’t see mlkem… or sntrup…, see key exchange.

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

If you see an Ed25519 key or an RSA key that is less than 3072, see authentication.

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

Alternatively, check your publicly registered keys: https://github.com/$GITHUB_USERNAME.keys

fixing

key exchange

Neither OpenSSH 10.6 nor GitHub offers purely PQC options (ML-KEM/FIPS 203). As of 2026-09-22, GitHub offers mlkem768x25519-sha256, so a hybrid PQC scheme is the best we can do for now — in line with the NSA advisory.

Some systems force potentially vulnerable defaults in /etc/ssh/crypto.conf. If you can’t modify that yourself on a managed laptop, put the following config in ~/.ssh/config.

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

Yes, it’s KexAlgorithms as in “key exchange”.

authentication

As of 2026-12-04, GitHub still suggests Ed25519 when generating new auth keys. That’s probably no longer a good idea, and GitHub doesn’t offer anything PQC for auth. The best we can do for now is use RSA-3072 or P-384.

  1. Generate a new key

    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"
    
  2. Register your new public key as an authentication key at https://github.com/settings/keys

  3. Either move your old Ed25519 keys out of ~/.ssh or add IdentityFile and IdentitiesOnly values to ~/.ssh/config for GitHub.

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

verified commits

If you use SSH verified commits:

  1. Register your new public key as a signing key at https://github.com/settings/keys

  2. Update your signing key in ~/.gitconfig

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

validation

You’ll want to clean up any existing ControlPath connections and add your new key to your ssh agent for the new key to be effective for git operations.

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

Then run:

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
    }'

… prints PASS kex=mlkem768x25519-sha256 auth=ECDSA-384 for me.

Related tags:

email comments to [email protected]

Back to top

联系我们 contact @ memedata.com