# Hardening Client SSH, Servers and Git Repositories for Post-Quantum Security

> Step-by-step hands-on commands, private-key rotation workflows and copyable configs for OpenSSH 9.9–10.6, macOS, Windows OpenSSH, Ubuntu 24.04/26.04 LTS, GitHub/GitLab, Campus Moodle SSO, Nginx/Caddy and age backups — plus an interactive configurator.

- URL: https://gigantic.work/tutorials/hardening-ssh-servers-and-git-for-post-quantum/
- Published: 2026-12-03
- Author: Gigantic Work (Engineering team)
- Topics: SSH, OpenSSH, Git, Ubuntu, Windows, Moodle, Post-Quantum, Post-AI
- Language: English

NSA Advisory **PP-26-4956** (*Immediate Actions to Push Toward Post-Quantum*) — co-announced alongside a rare joint statement from eight major tech companies (Amazon, Anthropic, Apple, Cloudflare, Google, Microsoft, OpenAI and Oracle) and Cloudflare CEO Matthew Prince's warning to shift to *"post-quantum (maybe more appropriately called post-AI) standards"* — raises one immediate engineering question: **what exact commands and configuration files do we change today on developer laptops, servers, Git repositories and campus SSO without locking ourselves out?**

This guide gives you the exact audit commands, private-key rotation sequence, OS-specific fixes for **macOS, Windows OpenSSH and Ubuntu Server (22.04 / 24.04 / 26.04 LTS)**, **Git & CI/CD** workflows, **Campus Moodle / SSO** rollover steps, and an interactive configurator that builds a tailored runbook for your environment.

<div class="callout callout-tip">
  <div class="callout-title">Safety rule before touching remote SSH</div>
  <p>Always keep a second root or console session open in another terminal window, validate server configuration with <code>sudo sshd -t</code> before reloading, and test a fresh login in a third terminal before closing your safety session.</p>
</div>

---

## 1. Interactive Post-Quantum / Post-AI Hardening Configurator

Choose your workstation OS, private-key rotation posture and server stack below to generate a copyable runbook covering private-key commands, SSH/Ubuntu/Windows/Git/Moodle/TLS configs, read-only audits and upgrade traps.

_(Interactive demo: try it on the web page, https://gigantic.work/tutorials/hardening-ssh-servers-and-git-for-post-quantum/)_

---

## 2. Step 1 — Audit what you actually run (read-only)

Do not assume your workstation or server already negotiates post-quantum key exchange. Run these read-only checks first:

```bash
# 1. Check OpenSSH version and supported PQ key-exchange algorithms
ssh -V
ssh -Q kex | grep -E "mlkem|sntrup"
ssh -Q key | grep -E "mldsa|sk-ecdsa|ecdsa"

# 2. See what your client ACTUALLY negotiates with GitHub or a server
ssh -vv -o BatchMode=yes -o ConnectTimeout=5 git@github.com 2>&1 \
  | grep -iE "kex: algorithm|host key|WARNING:.*post-quantum"

# 3. Inspect every local public key for RSA < 3072 bits or legacy DSA
for f in ~/.ssh/*.pub; do [ -f "$f" ] && ssh-keygen -lf "$f"; done

# 4. Test whether your web server / Moodle origin negotiates TLS 1.3 X25519MLKEM768
openssl s_client -groups X25519MLKEM768 -tls1_3 -connect your-domain.example:443 </dev/null 2>/dev/null \
  | grep -E "Protocol|Negotiated TLS1.3 group|Server public key"
```

If step 2 prints `** WARNING: connection is not using a post-quantum key exchange algorithm` (introduced in **OpenSSH 10.1**) — or if `ssh -Q kex` returns nothing at all — you have identified your first upgrade targets.

---

## 3. Step 2 — Rotate private keys urgently (and drop weak RSA / 256-bit-only habits)

Because public keys are exposed across GitHub/GitLab profiles, `known_hosts`, commit signatures and SAML metadata, **rotating long-lived private keys off legacy algorithms is just as urgent as fixing key exchange**:

- **Retire immediately:** `ssh-rsa` (SHA-1 signatures), DSA (`ssh-dss`), RSA-1024 and RSA-2048 SSH/SAML/GPG keys, and unrotated static RSA deploy keys.
- **Avoid the 256-bit ECC trap:** NSA PP-26-4956 flags EdDSA (`Ed25519`) and elliptic curves other than `P-384` or `P-521`, while accepting **RSA-3072+** and **P-384** as classical interim baselines where pure PQC signatures are unavailable.

Generate clean replacement keys according to where they will be used:

```bash
# A. OpenSSH 10.6+ servers & workstations (hybrid PQ + classical Ed25519)
ssh-keygen -t mldsa44-ed25519 -a 100 -C "alice@org-2026-pqc" -f ~/.ssh/id_mldsa44_ed25519

# B. Hardware security key (FIDO2/WebAuthn resident or non-resident key)
ssh-keygen -t ecdsa-sk -O resident -a 100 -C "alice-yubikey-2026" -f ~/.ssh/id_ecdsa_sk

# C. Interim key for GitHub / GitLab / older bastions (CNSA interim baseline)
ssh-keygen -t ecdsa -b 384 -a 100 -C "alice-git-p384-2026" -f ~/.ssh/id_ecdsa_p384
# Or if an external system requires RSA:
ssh-keygen -t rsa -b 4096 -a 100 -C "alice-legacy-rsa4096-2026" -f ~/.ssh/id_rsa_4096

# D. Long-retention encrypted backups & secrets (hybrid ML-KEM-768 + X25519)
age-keygen -pq -o ~/.config/age/pqc-identity.txt
```

<div class="callout callout-danger">
  <div class="callout-title">OpenSSH 10.4 / 10.5 to 10.6 upgrade crash warning</div>
  <p>OpenSSH 10.4 introduced experimental <code>mldsa44-ed25519@openssh.com</code> keys; OpenSSH 10.6 enabled the final standard name <code>ssh-mldsa44-ed25519</code> and dropped the vendor suffix. Any host or user key generated with the experimental <code>@openssh.com</code> suffix will cause <code>sshd</code> 10.6+ to fail on startup until removed from disk, <code>sshd_config</code> and <code>known_hosts</code> and regenerated cleanly.</p>
</div>

---

## 4. Step 3 — Harden client workstations (macOS, Linux & Windows OpenSSH)

### macOS & Linux workstations

On macOS, `/usr/bin/ssh` often lags behind Homebrew. Install `openssh` via Homebrew, confirm `which -a ssh` puts `/opt/homebrew/bin/ssh` (Apple Silicon) or `/usr/local/bin/ssh` first in `PATH`, and place this policy in `~/.ssh/config` (`chmod 600 ~/.ssh/config`):

```ssh-config
Host *
    KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512@openssh.com,ecdh-sha2-nistp384
    RequiredRSASize 3072
    WarnWeakCrypto yes
    HostKeyAlgorithms ssh-mldsa44-ed25519,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256
    PubkeyAcceptedAlgorithms ssh-mldsa44-ed25519,sk-ecdsa-sha2-nistp256@openssh.com,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256
    Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com
    MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com
    IdentitiesOnly yes
    IdentityFile ~/.ssh/id_mldsa44_ed25519
    IdentityFile ~/.ssh/id_ecdsa_p384
    IdentityFile ~/.ssh/id_rsa_4096

# Ticketed legacy host exception — never silence warnings globally
Host legacy-switch.internal
    WarnWeakCrypto no-pq-kex
```

Do **not** set `WarnWeakCrypto no` globally: silencing the warning hides active *Store Now, Decrypt Later* exposure across the rest of your fleet.

### Windows OpenSSH (`Win32-OpenSSH`) and Git-for-Windows

Windows bundles an inbox OpenSSH build under `C:\Windows\System32\OpenSSH\` that lags upstream OpenSSH releases and frequently lacks `mlkem768x25519-sha256`. Worse, **Git-for-Windows** ships its own MSYS2 `ssh` unless overridden.

Fix Windows clients in three steps:

```powershell
# 1. Inspect which ssh binary Windows and Git are actually invoking
where.exe ssh
ssh -V
ssh -Q kex

# 2. Install current PowerShell/Win32-OpenSSH (or run OpenSSH 10.x inside WSL2 Ubuntu 26.04)
winget install Microsoft.OpenSSH.Beta

# 3. Force Git-for-Windows to use the upgraded OpenSSH binary (adjust path if using WSL2 wrapper)
git config --global core.sshCommand "C:/Program Files/OpenSSH/ssh.exe"
```

Place the same `Host *` policy in `%USERPROFILE%\.ssh\config`. On **Windows OpenSSH servers**, edit `C:\ProgramData\ssh\sshd_config`, set `RequiredRSASize 3072`, add PQ `KexAlgorithms`, and watch out for the classic Windows pitfall: members of the `Administrators` group authenticate against **`C:\ProgramData\ssh\administrators_authorized_keys`** (not `%USERPROFILE%\.ssh\authorized_keys`), which fails silently if NTFS inheritance is not restricted to `SYSTEM` and `Administrators`:

```powershell
icacls.exe "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
Restart-Service sshd
```

---

## 5. Step 4 — Harden Ubuntu Server (22.04, 24.04 and 26.04 LTS)

Pick your path by Ubuntu release:

| Ubuntu release | Stock OpenSSH & OpenSSL | Practical hardening move |
| :--- | :--- | :--- |
| **Ubuntu 22.04 LTS** | OpenSSH 8.9 (no PQ KEX) · OpenSSL 3.0 | **Upgrade or replace urgently**, or isolate behind an Ubuntu 26.04 bastion + PQ reverse proxy |
| **Ubuntu 24.04 LTS** | OpenSSH 9.6 (`sntrup761x25519` only) · OpenSSL 3.0 | Enforce `sntrup761x25519-sha512@openssh.com` in `sshd`; put **Caddy 2.10+** or an Ubuntu 26.04 proxy in front for `X25519MLKEM768` TLS 1.3; schedule 26.04 upgrade |
| **Ubuntu 26.04 LTS** | OpenSSH 10.2+ (`mlkem768x25519-sha256`) · OpenSSL 3.5 | Native PQ KEX in SSH and native `X25519MLKEM768` / `SecP384r1MLKEM1024` in Nginx/Apache |

Drop a dedicated policy file at `/etc/ssh/sshd_config.d/99-pqc-hardening.conf` (include `sntrup761x25519-sha512@openssh.com` on 24.04; use `mlkem768x25519-sha256` first on 26.04+):

```ssh-config
# /etc/ssh/sshd_config.d/99-pqc-hardening.conf
KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512@openssh.com
# If supporting OpenSSH 10.6+ host keys:
HostKey /etc/ssh/ssh_host_mldsa44_ed25519_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKeyAlgorithms ssh-mldsa44-ed25519,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256
PubkeyAcceptedAlgorithms ssh-mldsa44-ed25519,sk-ecdsa-sha2-nistp256@openssh.com,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256
RequiredRSASize 3072
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin prohibit-password
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com
```

Validate and apply without dropping active sessions:

```bash
# On OpenSSH 10.6+, generate missing host keys (including ssh_host_mldsa44_ed25519_key):
sudo ssh-keygen -A

# Remove weak legacy DSA / small RSA host keys if present
sudo rm -f /etc/ssh/ssh_host_dsa_key*

# Syntax check BEFORE reloading
sudo sshd -t && sudo systemctl reload ssh
```

---

## 6. Step 5 — Secure Git repositories and CI/CD pipelines

1. **Verify post-quantum Git-over-SSH transport:** GitHub already serves `sntrup761x25519-sha512` on `git@github.com`, while GitLab requires `gitlab-sshd` &gt;= 18.2.4 or host OpenSSH 9.9+. For self-hosted Git (Gitea, Forgejo, GitLab) running on older hosts, either upgrade host OpenSSH or route developers over **HTTPS with TLS 1.3 `X25519MLKEM768`** via Caddy 2.10+ / Nginx + OpenSSL 3.5+.
2. **Eliminate static RSA deploy keys and long-lived PATs:** Replace SSH deploy keys and static cloud IAM credentials in CI with **OIDC workload identity federation** (GitHub Actions `id-token: write` or GitLab CI `id_tokens` authenticating directly to AWS, Azure, GCP or Cloudflare) and short-lived GitHub App installation tokens.
3. **Sign commits and tags with SSH (and verify via `allowed_signers`):**

```bash
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ecdsa_p384.pub
git config --global gpg.ssh.allowedSignersFile ~/.config/git/allowed_signers
git config --global commit.gpgsign true
git config --global tag.gpgSign true
```

Commit your team's `~/.config/git/allowed_signers` mapping (`email ssh-ecdsa-sha2-nistp384 ...`) inside institutional repos and enable signed-commit branch protection on `main`. When a member rotates a key, add the new key line alongside the old one rather than overwriting history, so past signatures still verify locally.

---

## 7. Step 6 — Campus Moodle, SSO, web TLS, VPNs and backups

### Campus Moodle & SAML 2.0 / OIDC / LTI 1.3

University Moodle platforms typically hide long-lived RSA-2048 private keys inside `auth_saml2`, SimpleSAMLphp, Shibboleth SP (`/etc/shibboleth/sp-signing-key.pem`, `sp-encrypt-key.pem`) and LTI 1.3 / OIDC tool registrations. To rotate without breaking term-time logins:

1. Generate a new **RSA-4096** (or **P-384**) signing keypair (`openssl genrsa -out sp-signing-next.key 4096`).
2. Add the new public certificate alongside the existing one in a **chaining `CredentialResolver`** (or IdP metadata / JWKS `kid` array) first, wait for IdP metadata caches to refresh (usually 24–72 hours), and only then switch the active signing key and retire the old RSA-2048 key.
3. Enforce **SHA-256 or SHA-384** XML signatures and **AES-256-GCM** XML encryption (disable legacy SHA-1 and `RSA-PKCS1-v1.5`).
4. Terminate Moodle HTTPS on **TLS 1.3 with `X25519MLKEM768`** (Cloudflare Edge + Origin, Caddy 2.10+ or Ubuntu 26.04 Nginx) and encrypt nightly `moodledata` + PostgreSQL/MySQL backups with `age -pq`.

### Nginx (OpenSSL 3.5+), Caddy 2.10+, WireGuard and `age` backups

- **Nginx (Ubuntu 26.04 / OpenSSL 3.5+):** set `ssl_protocols TLSv1.3;` and `ssl_ecdh_curve X25519MLKEM768:SecP384r1MLKEM1024:X25519;` inside your server block, and log `$ssl_curve` to track client coverage.
- **Caddy 2.10+:** add `curves x25519mlkem768 secp384r1mlkem1024` inside `tls { protocols tls1.3 ... }` — ideal as a lightweight PQ front proxy for Ubuntu 24.04 origins.
- **WireGuard VPNs:** pair standard WireGuard peers with a 256-bit `PresharedKey` rotated regularly, or automate PQ PSK rotation with **Rosenpass** without touching kernel WireGuard interfaces.
- **Archival backups:** switch nightly database and document-store snapshots to `age` hybrid `mlkem768x25519` (`age-keygen -pq`) and hold the decryption identity offline.

---

## 8. Zero-lockout verification checklist

- [ ] `ssh -V` and `ssh -Q kex` confirm `mlkem768x25519-sha256` (or at minimum `sntrup761x25519-sha512`) on every engineer's macOS, Linux and Windows OpenSSH client
- [ ] All user and server SSH keys &lt; 3072-bit RSA, `ssh-rsa` (SHA-1), DSA and stale `@openssh.com` experimental keys removed and rotated
- [ ] Git-for-Windows points to upgraded OpenSSH (`core.sshCommand`); static deploy keys replaced with OIDC; SSH commit signing active
- [ ] Ubuntu servers validated with `sshd -t`; Ubuntu 22.04 scheduled for upgrade or isolated behind a PQ bastion/proxy
- [ ] Campus Moodle SAML 2.0 / OIDC / LTI 1.3 signing keys rotated via dual-key metadata overlap; AES-256-GCM and PQ TLS 1.3 verified end-to-end
- [ ] Offsite database and file backups encrypted with `age` `mlkem768x25519` and a restore tested

For the architectural deep dives behind these configurations, read our Engineering Notes on [Post-Quantum SSH and Git Infrastructure](https://gigantic.work/engineering/post-quantum-ssh-and-git-hardening/) and [Crypto-Agility for Client Servers](https://gigantic.work/engineering/crypto-agility-for-client-servers-and-tls/). Need hands-on help hardening your servers, Git repositories or campus SSO? [Book a security review](https://gigantic.work/contact/?topic=DevOps).

---

Published by Gigantic Work, an IT vendor with a team in London and Hong Kong, building AI, learning platforms, web platforms, research portals, cloud and 3D/VR projects for universities, grant-funded projects, NGOs, schools and SMEs. Contact: info@gigantic.work · https://gigantic.work/contact/ · Site overview: https://gigantic.work/llms.txt
