SSH: keys, certificates, jump hosts and tunnels for cluster work

How SSH builds one trusted, encrypted pipe and carries shells, file copies and tunnels inside it, recorded in a small container cluster with ssh -vvv. Data as of October 2026 (lab run of 5 October 2026). Reading: 42 min, plus 33 in closed details.

The idea in one screen

SSH is one encrypted TCP connection in which the server first proves who it is with its host key, you then prove who you are with a key or certificate, and any number of independent channels (a shell, a file copy, a tunnel) then share that pipe. Every cluster pattern on this page is a way of nesting or reusing those channels: ProxyJump runs a second, end-to-end SSH session inside a channel of the first, ControlMaster lets later commands open channels on a pipe that is already authenticated, and port forwarding carries TCP connections as channels.

Fig. 1 builds one login, ssh bastion true, from the bottom up, with the sizes the lab recorded (default key exchange, laptop OpenSSH 10.3p1 to bastion OpenSSH 10.5p1). The lab: a laptop, a bastion published on 127.0.0.1:30922, and two compute nodes on an internal network the laptop cannot route to (gpu-node-01 runs a token-protected stand-in for Jupyter; gpu-node-02 plays an old login node).

  1. One TCP connection. Everything rides one TCP connection to port 22: lose it and every channel goes with it.
  2. Hello, in the clear. Each side sends its identification string (SSH-2.0-OpenSSH_10.3, SSH-2.0-OpenSSH_10.5) and a KEXINIT listing what it supports (1672 and 1040 bytes). Anyone on the path can read all of it (section 1).
  3. Key exchange and the host key. The laptop sends a fresh public value (1232 bytes for the post-quantum hybrid); the bastion replies with its own, its host key and a signature over the exchange (1280 bytes). The laptop checks the host key against known_hosts (sections 3 and 4).
  4. NEWKEYS: encryption on. Both sides switch keys; from here an observer sees only sizes: 888 bytes up and 2040 down for the rest of this login.
  5. User authentication, inside. The laptop signs a message that includes the session identifier H, so the signature is useless on any other connection; the bastion checks it against authorized_keys (section 2).
  6. Channels share the pipe. A shell, an rsync and a tunnel to a notebook are independent channels on the one connection (illustrative lanes; sections 7 and 8).
  7. Nest it: ProxyJump. One channel can carry a complete second SSH session, end to end from the laptop to gpu-node-01: the bastion relays ciphertext it cannot read (sections 5 and 6).
You need

TCP connections and round trips (Networking foundations); Diffie-Hellman key agreement and signatures, and how X.509 certificates work (TLS and certificates, section 1). Login nodes and Slurm jobs are on Cluster anatomy and Slurm.

Seven rules this page records

1. Never click through a changed host key; use host certificates where nodes churn (3, 4). 2. ProxyJump, not agent forwarding (6). 3. Turn on ControlMaster: 850 ms to 114 ms per command (7). 4. Loopback is shared by every user of a node: serve notebooks on a private Unix socket (8). 5. Short-lived certificates beat authorized_keys at scale (4). 6. Post-quantum key exchange is already the default and costs nothing measurable (11). 7. Patch, and keep port 22 off the internet: pre-authentication bugs ignore your keys (12).

New terms on this page
bastion, jump host
The one machine reachable from outside, through which you reach the private network: a hardened machine whose one job is to let authenticated people through.
host key
The server's long-term key pair; proves the server's identity in every key exchange.
known_hosts
The client's list of host keys it trusts (trust on first use), or @cert-authority lines.
TOFU
Trust on first use: accept a key the first time, insist on it afterwards.
authorized_keys
The server-side list of user public keys allowed to log in to an account.
agent
ssh-agent: holds decrypted private keys and signs on request over a Unix socket.
certificate (SSH)
A public key plus key ID, principals, validity and options, signed by a CA key; not X.509.
principal
A name a certificate is valid for: a user account (user certificates) or a host name (host certificates).
KRL
Key revocation list: a compact file of revoked keys and certificate serials.
channel
One independent stream inside an SSH connection: session, direct-tcpip, forwarded-tcpip, agent, X11.
ProxyJump
Reach a host through another by tunnelling a second, end-to-end SSH session through a direct-tcpip channel.
ControlMaster
Connection multiplexing: later clients reuse one authenticated connection through a control socket.
session identifier
The hash of the first key exchange; signatures in user authentication cover it, binding them to one connection.
strict KEX
OpenSSH 9.6's fix for Terrapin: no unexpected handshake messages, sequence numbers reset at each key exchange.
hybrid key exchange
A classic and a post-quantum exchange run together, the secret derived from both, so it is at least as strong as either.
How this page was recorded
SSH (Secure Shell, protocol version 2) runs on TCP, by default on port 22, and the implementation almost everyone uses is OpenSSH (client ssh, server sshd); the current release is 10.5, of 11 August 2026 (OpenSSH release notes). The laptop client is OpenSSH 10.3p1 (macOS); the bastion and gpu-node-01 run OpenSSH 10.5p1 (Alpine edge), gpu-node-02 runs Alpine 3.20's patched 9.7p1, configured with no post-quantum key exchange to play an old node. The lab account is called dev, a second local user alice. Every ssh call used -F with the lab's own config, so no personal key or known_hosts was touched; private keys never left the lab directory. An observer was simulated with a small relay on the laptop that decodes the SSH packets until encryption starts (no packet capture tool was used, so nothing below the TCP payload is shown). Where a delay is stated, 40 ms was added to the bastion's outward link with tc netem. Installing Jupyter adds nothing to the protocol story, so the notebook is a token-protected Python web server. Logs are verbatim except that the lab directory is written $LAB and the laptop's name laptop; -vvv logs are trimmed of per-packet lines; addresses such as 172.21.0.2 are the containers' private network. Scripts and raw outputs: src/lab/, src/raw/; rerun with src/run_all.sh.
Everything before NEWKEYS is readable on the path; the post-quantum hybrid makes the key exchange about ten times bigger and the login no measurably slower.

Recorded 5 October 2026, laptop OpenSSH 10.3p1 to bastion OpenSSH 10.5p1, one connection per key exchange (forced with -o KexAlgorithms=). Bars to scale by bytes on the wire; sizes are whole SSH packets (length field, padding included). Time is the median of 15 fresh logins with no added delay; most of it is the container port proxy, not cryptography.

1. One connection on the wire

Before SSH (1995), telnet and rlogin sent everything, passwords included, as readable text, and rcp and ftp copied files the same way. SSH replaced all of them with one protocol that encrypts and authenticates. Version 2, the only one in use, is four RFCs from January 2006: the architecture (RFC 4251), user authentication (RFC 4252), the transport layer (RFC 4253) and the connection protocol (RFC 4254), plus many later extensions.

The three layers on one TCP connection are the stack of Fig. 1 (lose the connection and every channel goes with it):

  • Transport (RFC 4253). After TCP connects, each side sends one text line, its identification string (here SSH-2.0-OpenSSH_10.3 and SSH-2.0-OpenSSH_10.5: anyone on the path sees your software version). Both then send KEXINIT, a list of what they support in ten categories (key exchange, host key type, cipher and MAC each way, compression, languages); in each category the winner is the first entry on the client's list that the server also supports (RFC 4253 section 7.1). Then a key exchange (Diffie-Hellman style: each side sends a fresh public value, both compute the same secret, an eavesdropper cannot), in which the server also signs a hash of everything exchanged so far with its host key. That hash, H, becomes the session identifier. Both send NEWKEYS and switch on encryption.
  • User authentication (RFC 4252) runs inside the encrypted pipe; section 2.
  • Connection (RFC 4254) multiplexes channels, each with its own flow-control window: session (a shell, a command, or a subsystem such as SFTP), direct-tcpip (reach a host and port through the server: -L, -D and ProxyJump), forwarded-tcpip (the server forwards a connection back to you: -R), and channels for X11 and the agent. One login can carry a shell, an rsync and three tunnels at once, and one dead TCP connection kills all of them together.

Watch one login, packet by packet

A relay between the laptop and the bastion decoded every SSH packet of ssh bastion true (log in, run nothing, leave) until encryption started; after NEWKEYS it could see only sizes. Predict before you step: how much bigger is the post-quantum default's key exchange than the classic one, and how much slower is the login?

    The sizes, then the formula. Key-exchange messages: 2512 bytes for the hybrid against 240 for classic X25519; median login 61 ms against 56 ms. In the hybrid, the client's KEX_HYBRID_INIT carries an X25519 public key (32 bytes) and an ML-KEM-768 encapsulation key (1,184 bytes); the reply carries an X25519 key and a 1,088-byte ML-KEM ciphertext, plus the host key and signature (sizes from FIPS 203; layout in RFC 10042 section 2.1). Payload of the recorded init: 1 (message type) + 4 (length) + 32 + 1,184 = 1,221 bytes, exactly what the relay saw. The two secrets are combined as K = HASH(KPQ || KCL) (RFC 10042 section 2.4), so the result is safe if either half holds. The rest of the login (authentication, one channel, exit status) was 888 encrypted bytes up and 2040 down, the same for every key exchange.

    Predict, then reveal: what can the relay (or anyone on the Wi-Fi) learn from this login?
    Both software versions (the identification strings), every algorithm each side supports and which ones were chosen (KEXINIT is plaintext), the server's host key (it is in the reply, so a passive observer can fingerprint the server), and then the sizes and timing of every encrypted packet. Not visible: the user name, which key was used, the command, its output. Keystroke timing in interactive shells is partly hidden since OpenSSH 9.5's ObscureKeystrokeTiming (on by default; OpenSSH 9.5 release notes).

    How many round trips a login costs

    With 40 ms added between laptop and bastion, the server's banner arrived at 123 ms (TCP setup plus the first round trip, plus the container proxy), keys were in place at 176 ms, and the command finished at 480 ms: about eight round trips for one ssh host command. Through a jump host you pay that twice, the second set inside the first (section 5); section 7 removes it. Every arrow is a real packet group at its real time; labels after NEWKEYS are inferred from order, size and the client's -vvv log.

    Reading ssh -vvv. -v prints the client's view of each step; -vv and -vvv add detail. The lines worth finding are in the closed block below; the one to remember: for each option the first value obtained wins, so specific Host blocks go before Host *.

    About eight round trips before any work is done: the cost that connection reuse removes.
    The -vvv lines worth finding, from the recorded log of this login
    LineTells you
    Reading configuration data ..., Applying options for ...which config file and which Host blocks matched. For each option the first value obtained wins, so specific blocks go before Host *.
    Connecting to 127.0.0.1 [127.0.0.1] port 30922.the address actually dialled (after HostName, DNS and any proxy)
    Remote protocol version 2.0, remote software version OpenSSH_10.5the server's banner
    kex: algorithm: mlkem768x25519-sha256, kex: host key algorithm: ssh-ed25519what was negotiated (the cipher lines follow)
    Server host key: ssh-ed25519 SHA256:..., Host 'bastion' is known and matchesthe host key check (section 3)
    Authentications that can continue: publickeymethods the server will accept
    Offering public key: ..., Server accepts key: ...each key tried, in order (section 2)
    Authenticated to ... using "publickey".login done; then channel 0: new [client-session] and the request
    The recorded ssh -vvv bastion true (trimmed of per-packet lines)
    Rekeying, and a 10.4 change
    A long connection agrees new keys from time to time. RFC 4253 section 9 recommends after each gigabyte or each hour; the log shows OpenSSH's default for ChaCha20-Poly1305, rekey out after 134217728 blocks (227 blocks), and RekeyLimit sets it. Since OpenSSH 10.4 a peer that sends non-key-exchange messages during a post-authentication rekey is disconnected (10.4 release notes).
    Go deeper. The same ideas in TLS, with every record decrypted: TLS and certificates, section 1 (building blocks) and its Handshake tab. TCP itself (the connect, windows, why round trips dominate): Networking foundations.

    2. Keys, agents and authentication

    Passwords sent to a server can be guessed, phished, reused and brute-forced, and they are the whole input of the internet's SSH-guessing botnets. A key pair fixes that: a private key that never leaves your machine and a public key you can hand to anyone. To log in, the client signs a message that includes the session identifier from section 1; the server checks the signature with the public key listed in ~/.ssh/authorized_keys.

    The user signature covers this connection's session identifier, so it is useless on any other connection.
    session identifier HSSH_MSG_USERAUTH_REQUESTuser nameservice ssh-connection"publickey"algorithmyour public keyserver host key (hostbound only)

    Signed with your private key; the server verifies with the public key in authorized_keys. Field list from RFC 4252 section 7; OpenSSH's publickey-hostbound-v00@openssh.com also binds the server's host key into the signature (seen in the recorded log in section 1), so a malicious server cannot replay the signature elsewhere.

    Making and protecting a key

    ssh-keygen -t ed25519 -C "dev@laptop"         # Ed25519 is the default type since OpenSSH 9.5
    ssh-keygen -p -a 100 -f ~/.ssh/id_ed25519      # add or change the passphrase, with more KDF rounds
    • Ed25519 (RFC 8709): 32-byte public keys, fast, no parameters to get wrong and no random number needed per signature. RSA still works (signed with rsa-sha2-512); DSA was removed entirely in OpenSSH 10.0 (9 April 2025), "completing the deprecation process that began in 2015" (10.0 release notes).
    • The passphrase encrypts the private key file on disk, stretched with bcrypt_pbkdf; -a sets the rounds. It protects a stolen file, nothing else: once the key is in an agent, anything that can talk to the agent can use it.
    • Hardware keys (FIDO tokens, OpenSSH 8.2, February 2020): ssh-keygen -t ed25519-sk keeps the private key inside the token and needs a touch per login; -O resident stores it on the token so you can load it on another machine, -O verify-required adds a PIN. The server must run OpenSSH 8.2 or newer.
    • On the server, each authorized_keys line can limit the key: restrict (no forwarding, no pty), from="198.51.100.0/24", command="..." (this key may only run one command: backup or CI keys). See sshd(8) AUTHORIZED_KEYS FILE FORMAT.

    The agent

    ssh-agent holds your decrypted keys in memory and signs on request through a Unix socket named by SSH_AUTH_SOCK: you type the passphrase once, and ssh, git and rsync use the key without seeing it. Useful flags: ssh-add -t 8h (forget the key after 8 hours), ssh-add -c (confirm every use), ssh-add -l (list). Since 10.1 agent sockets live under ~/.ssh/agent/ instead of /tmp, so a sandboxed process that can read /tmp no longer reaches your keys (the forwarded socket on the bastion in section 6 is at /home/dev/.ssh/agent/s.…); scripts that hard-coded /tmp/ssh-XXXX break.

    KDF rounds, and the agent protocol as an RFC
    The default number of bcrypt_pbkdf rounds for -a: the 10.3 manual gives 16; the current OpenBSD manual says 32. The agent protocol is now RFC 9987 (Standards Track, May 2026); since OpenSSH 10.3 the IANA-assigned names are used when the server offers them, which is why the recorded server advertises an agent-forward extension in its EXT_INFO.

    Which key gets offered, and "Too many authentication failures"

    The client offers keys one at a time, and each refusal counts against the server's MaxAuthTries, 6 by default (recorded with sshd -T). An agent full of keys exhausts it before the right key is tried: recorded with seven unrelated keys in the agent and the right key named in IdentityFile, the server disconnected with "Too many authentication failures". The fix is IdentitiesOnly yes, which offers only the keys your config names. To see the order without connecting, OpenSSH 10.5 added ssh -Z host (recorded with the bastion's 10.5 client; the laptop's 10.3 lacks it); it lists the default identity names, including the new id_mldsa44_ed25519 (section 11).

    A trap found while recording: IdentityFile lines add up
    For almost every keyword the first value obtained wins, which is why Host * goes last. IdentityFile is the exception: "Multiple IdentityFile directives will add to the list of identities tried" (ssh_config(5)). The first certificate tests on this page all "succeeded", even the expired certificate, because the Host * block's ordinary key was also offered and accepted. If a test of one key must fail, give it a config where no other IdentityFile applies, and check ssh -G host | grep identityfile.
    Recorded: too many keys in the agent, then IdentitiesOnly yes
    Recorded: ssh -Z (OpenSSH 10.5)
    Predict, then reveal: a malicious server you log in to receives your signature. Can it use it to log in to the bastion as you?
    No. The signed data includes the session identifier of that connection (RFC 4252 section 7), and OpenSSH's hostbound variant also includes the host key. The bastion's session has a different identifier, so the signature fails there. What a malicious server can do is ask a forwarded agent for fresh signatures while you are connected (section 6).
    The bastion's effective server settings (sshd -T, OpenSSH 10.5p1)
    A rebuilt node changes its key: the client refuses it, unless you told it not to care.
    
    

    Cloud and cluster nodes are often rebuilt from an image that generates new host keys at first boot; the lab did exactly that. Recorded: first contact with a new node (answered yes, with the fingerprint read on the node itself, the comparison you are supposed to make through another channel such as the cloud console, the admin or a provisioning log); the node rebuilt (a new container, so new host keys) under accept-new and under no; the stale line removed. Highlighted lines only; full logs below.

    3. Host keys, known_hosts and churn

    Encryption is worthless if you are encrypting to the attacker. In the key exchange the server signs the exchange hash with its host key, and the client must decide whether that key really belongs to gpu-node-01. TLS answers with certificate authorities; plain SSH answers with trust on first use (TOFU): the first time, it shows the key's fingerprint and asks; after that it remembers the key in ~/.ssh/known_hosts and insists on the same one. The first connection is the weak moment; every later one is protected. The host key is SSH's only defence against a man in the middle (an attacker on the path who pretends to be the server).

    1. First contact. Trust on first use: the fingerprint is shown and must be compared out of band, here with the one read on the node itself.
    2. The node is rebuilt: accept-new refuses. New host key. accept-new adds unknown hosts silently but still refuses a changed key: exit 255, "Host key verification failed".
    3. StrictHostKeyChecking no: it connects anyway. Exit 0: the public-key login ran the command on an unverified machine. Only password, keyboard-interactive and forwarding were blocked.
    4. After checking the new fingerprint: remove the stale line. ssh-keygen -R gpu-node-01 deletes the old entry (and keeps a backup); the next login is a first contact again.

    Two details from these logs. <no hostip for proxy command>: through a jump host the client never learns the node's address, so the entry is filed under the name only. And with StrictHostKeyChecking no the client logged in and ran the command: OpenSSH blocks password and keyboard-interactive login (an impostor would capture the password), and agent and port forwarding when requested, but a public-key login proceeds and you are now typing into a machine you have not verified. That is why no must never be a habit. The honest fix after a known rebuild: compare the new fingerprint out of band, then ssh-keygen -R host.

    StrictHostKeyCheckingUnknown hostKnown host, changed key
    ask (default)shows the fingerprint, asksrefuses
    accept-newadds silentlyrefuses (recorded)
    yesrefuses (recorded: No ED25519 host key is known for gpu-node-02 and you have requested strict checking.)refuses
    noadds silentlyconnects, with some features disabled (recorded)

    Behaviour from ssh_config(5), each cell confirmed in the lab except "ask, changed".

    The real risk of churn is habituation
    A team whose nodes change keys weekly learns to run ssh-keygen -R without looking, and the one day it is a real man in the middle it gets the same treatment. Three ways out, best first: host certificates (section 4: nothing changes on the client when a node is rebuilt); a separate, throwaway known_hosts with accept-new scoped to the ephemeral nodes only (Host gpu-node-*, never Host *, never the bastion); or distributing the keys (a managed /etc/ssh/ssh_known_hosts, or SSHFP below).
    Recorded logs: first contact, changed key under accept-new and no, removing the entry
    Other knobs: HashKnownHosts, UpdateHostKeys, SSHFP and CVE-2025-26465
    • HashKnownHosts yes stores names as hashes so a stolen known_hosts does not list every machine you use (default no upstream; some distributions turn it on). Lookups still work; ssh-keygen -F host finds an entry.
    • UpdateHostKeys: after login the server can send all its host keys (signed), so the client learns the others before a key rotation (the "hostkeys" extension in PROTOCOL).
    • SSHFP DNS records publish host key fingerprints; VerifyHostKeyDNS yes makes the client trust them. Only meaningful if the answer is DNSSEC-validated (see DNS), and it had a real bug: CVE-2025-26465, an on-path attacker could impersonate any server when VerifyHostKeyDNS was on, OpenSSH 6.8p1 to 9.9p1, fixed in 9.9p2 (18 February 2025, found by Qualys; release notes). Since 10.1 the release notes warn that SHA-1 SSHFP records will be ignored in a future release; publish SHA-256 ones (ssh-keygen -r host).
    Predict, then reveal: the bastion's key changed and you are sure nobody rebuilt it. What do you do?
    Stop. Do not remove the entry. Read the fingerprint the warning printed, get the real one through another channel (console, admin, a colleague on a different network), and compare. If they differ, someone is on the path or the server was compromised; if they match, the key really changed and you can update known_hosts. On a cluster with host certificates this situation becomes rare and therefore alarming, which is the point.

    4. SSH certificates: user and host

    With plain keys, trust is a list on every machine: N users' public keys in authorized_keys on M nodes, and M host keys in every user's known_hosts. Adding a person, removing a leaver, rebuilding a node all mean editing lists everywhere. SSH certificates replace the lists with one trusted certificate authority (CA) key: the CA signs a statement "this public key belongs to dev, may log in as dev, until 01:15 tomorrow", and every node trusts anything the CA signed. Not X.509 (the web's format, on TLS and certificates): OpenSSH's own simpler format, since OpenSSH 5.4 in 2010 (PROTOCOL.certkeys), with no chains: one CA signs, and the CA key is configured directly.

    Before: every node lists every user's key. After: every node trusts one CA line, and nothing changes when people come and go.

    Illustrative fleet of 20 users and 50 nodes: plain keys need 20 × 50 = 1,000 authorized_keys entries and 50 host keys in every user's known_hosts; certificates need one TrustedUserCAKeys line per node and one @cert-authority line per user.

    A user certificate, made and used

    ssh-keygen -s user_ca -I dev@2026-10-05 -n dev -V +8h -z 42 id_cert_only.pub   # writes id_cert_only-cert.pub
    # on every node, once:   TrustedUserCAKeys /etc/ssh/user_ca.pub      (sshd_config)

    -I is the key ID that appears in the server's log, -n the principals (the account names it may log in as), -V the validity window, -z a serial number for revocation. Each case below was signed and tried against gpu-node-01; the left is all the client ever says, the right is the server's log. Predict first: what does the client print for an expired certificate?

    "Permission denied (publickey)" is all the client learns, deliberately, so an attacker learns nothing either. Since OpenSSH 10.1 the server logs "enough information to identify the certificate in addition to the reason" (10.1 release notes): that is the Refusing certificate ID ... Certificate invalid: expired line. Ask whoever can read /var/log/auth.log or journalctl -u sshd. On the accepted login the node's log names the certificate, its serial and the CA.

    • Short lifetimes are the real revocation. An 8-hour certificate stolen today is useless tomorrow, and nobody has to remember to revoke it. Since 10.1, ssh-add drops a certificate from the agent five minutes after it expires (-N disables this).
    • Revocation for the hours in between uses a KRL (key revocation list), a compact file of revoked serials or keys: ssh-keygen -k -f revoked.krl -s user_ca.pub spec, pushed to nodes and named by RevokedKeys; ssh-keygen -Q -f revoked.krl cert checks a certificate against it (recorded in the "revoked" case). Since 10.3 RevokedKeys accepts several files.
    • Restrictions travel in the certificate: -O no-port-forwarding, -O force-command=..., -O source-address=198.51.100.0/24. The recorded certificate carries the default extensions (permit-pty, permit-port-forwarding and so on).
    The client only ever says "Permission denied"; the reason is in the server log.
    With a host CA, a rebuilt node is accepted with nothing to edit, and a certificate for the wrong name is refused.
    
    

    Recorded: accepted with no prompt; the node rebuilt (new key, re-signed at boot, as an image or a cloud-init step would do); a certificate signed for gpu-node-99. Highlighted lines only; full logs below.

    Host certificates: the cure for churn

    The same idea in the other direction. Provisioning signs each node's host key with a host CA (ssh-keygen -s host_ca -h -I gpu-node-01-host -n gpu-node-01 -V +52w ssh_host_ed25519_key.pub), the node presents it (HostCertificate in sshd_config), and clients carry one line instead of one per node: @cert-authority gpu-node-* ssh-ed25519 AAAAC3Nza... in known_hosts.

    1. The node presents a host certificate. known_hosts holds only the bastion and one @cert-authority line; the node is accepted with no prompt.
    2. Rebuilt and re-signed. New key, new certificate at boot: still no prompt, nothing to edit on any client.
    3. A certificate for the wrong name. Signed for gpu-node-99: the CA line does not vouch for gpu-node-01, and no plain key is known either, so the login is refused.

    Who runs the CA. In practice a service signs after a single sign-on login, and the CA private key becomes the most valuable secret you have: keep it offline or in an HSM or KMS. The same short-lived-credential idea for services and agents (tokens, mTLS) is on Auth.

    CA services, signing with an agent-held key, and empty principals (with a correction)

    Signing by hand is fine for a lab; in practice: HashiCorp Vault's SSH secrets engine, Teleport (CA, short-lived certificates, session recording), Smallstep, or cloud equivalents; Netflix published BLESS, a Lambda-based CA. ssh-keygen -s can sign with a CA key held in an agent (-U; 10.2 fixed a bug in exactly that path).

    • Empty principals. ssh-keygen warns ("certificate will contain no principals"), and the node refused it (recorded). Before 10.3 a certificate with no principals matched any user when trusted through an authorized_keys line with cert-authority,principals=""; 10.3 made it match none. CAs trusted through TrustedUserCAKeys, as here, never had that behaviour (10.3 release notes).
    Correction to the old page
    It said 10.3 "changed empty-principal certificates from matching any principal to matching none, which broke sloppy CA tooling in April 2026". The change is real but narrower: it applied only to CAs trusted via authorized_keys principals="", not via TrustedUserCAKeys. That it "broke CA tooling" could not be confirmed from any primary source and is dropped.
    Recorded logs: the accepted user certificate; host certificates accepted, after rebuild, wrong name
    Predict, then reveal: a laptop with a valid 8-hour certificate is stolen at 09:00. What can the thief do, and what do you do?
    Until the certificate expires (and only if the private key is not passphrase-protected or the agent is unlocked), log in wherever its principals allow. Revoke its serial in the KRL and push it to the nodes for the remaining hours, and the stolen key cannot get a new certificate because the CA requires your single sign-on. Compare with a stolen plain key: valid until someone finds and deletes it from every authorized_keys.

    5. Jump hosts and ProxyJump

    Compute nodes are not routable from your laptop; only the bastion is. Logging in to the bastion and running ssh again from there makes the second login use keys on (or forwarded to) the bastion, and every tool (rsync, git, VS Code) would have to do the same dance. ProxyJump (OpenSSH 7.3, August 2016) does it properly: your laptop asks the bastion for a raw TCP stream to gpu-node-01:22 and then runs a second, complete SSH session from the laptop to the node through that stream.

    ssh -J bastion gpu-node-01                # one hop
    ssh -J bastion,login gpu-node-07          # two hops, in order
    # or in ~/.ssh/config, so every tool gets it:
    Host gpu-node-*
        ProxyJump bastion
    1. ProxyJump becomes a helper ssh -W. The client converts ProxyJump bastion into ProxyCommand ssh -W '[gpu-node-01]:22' bastion, a "stdio forward" whose standard input and output become the TCP stream, and logs in to the bastion. Recorded: Executing proxy command: exec ssh ... -W '[gpu-node-01]:22' bastion.
    2. The bastion opens a direct-tcpip channel. On the bastion, sshd accepts the key and logs a direct-tcpip request to gpu-node-01 port 22: it connects the stream and relays bytes. Its log shows nothing more about the node session.
    3. An end-to-end session with the node. Through that stream the laptop does a second key exchange, checks the node's host key itself and logs in: Authenticated to gpu-node-01 (via proxy).
    4. What the bastion sees, and what it costs. Ciphertext only, in both directions; and two logins, the second inside the first: 57 ms to the bastion, 112 ms to the node through it (bars to scale).

    What the bastion sees. The node's session is encrypted end to end between laptop and node; the bastion relays ciphertext. The relay on the laptop's path, during a ProxyJump session that pulled about 27 KB of output, decoded the bastion's handshake and nothing else: the node's banner, its key exchange and everything after travelled inside the outer encryption, 5116 bytes up and 6732 down, unreadable to the observer and to the bastion alike.

    What it costs. Two full logins, the second inside the first. Without added delay, ssh bastion true took 57 ms and ssh gpu-node-01 true through it 112 ms (medians of 10); with 40 ms between laptop and bastion, 429 ms against 850 ms. Section 7 removes most of that. Each hop's options come from its own Host block, so the bastion can use a hardware key and long multiplexing while nodes use a throwaway known_hosts; ProxyJump none disables an inherited jump.

    Recorded logs: the client's -vvv and the bastion's server log
    ProxyCommand, its history, and untrusted input in command lines (CVE-2025-61984)
    • History. Before 7.3 the same thing was written ProxyCommand ssh -W %h:%p bastion, and before 5.4, ProxyCommand ssh bastion nc %h %p. ProxyCommand still matters for non-SSH transports: AWS Session Manager, for example, provides one so that plain ssh, -J and rsync work over it (AWS docs).
    • Untrusted input. CVE-2025-61984 (fixed in 10.1, 6 October 2025): control characters in a user name from the command line or a %-expansion could lead to code execution when a ProxyCommand using %r was configured (CVE record); the scenario is a crafted ssh:// or git URL. 10.3 added validation of user and host names given to -J on the command line (not in config files). OpenSSH's own advice: never build ssh command lines from untrusted input.

    6. Agent forwarding against ProxyJump

    Agent forwarding (ssh -A, ForwardAgent yes) solves the same problem the old way: the bastion's sshd creates a socket there that relays signing requests back to the agent on your laptop, so ssh gpu-node-01 typed on the bastion can authenticate as you. The cost: anyone who can open that socket while you are connected can authenticate as you, to any server that trusts your key. That is the bastion's root, or any process running as your user there. Your private key never leaves the laptop, but it does not need to. Recorded three ways: in each, while the session was open, the lab played a malicious root on the bastion (look for agent sockets, list the keys, try to log in to both nodes as dev). Predict which of the three stops root completely. With -A, root on the bastion logged in to both nodes as you; a constrained key limited it to one; ProxyJump left nothing to steal.

    1. The laptop logs in to the bastion with -A. The laptop authenticates with its key. Because of ForwardAgent yes, the bastion's sshd creates a socket for this session that relays signing requests back to the laptop's agent.
    2. The bastion's ssh uses the forwarded agent. Typed on the bastion, ssh gpu-node-01 asks the socket to sign; the request travels back to the laptop, which signs. It worked: gpu-node-01.
    3. Root on the bastion finds the socket. Root lists sockets under /home/dev/.ssh/agent/ and runs ssh-add -l with it: the laptop's key is listed. Root needs no file and no passphrase.
    4. Root logs in to the nodes as dev. With the socket, root ran ssh dev@gpu-node-01 and ssh dev@gpu-node-02. Recorded: both logged in.

    The three results, from src/raw/agent_*.txt: with plain forwarding root found /home/dev/.ssh/agent/s.…, listed the laptop's key, and logged in to both nodes as dev. With a destination-constrained key (ssh-add -h bastion -h 'bastion>gpu-node-01', OpenSSH 8.9 and later) root could still use it, but only for the hop you allowed: gpu-node-01 worked, gpu-node-02 was refused, because the agent checks each request against the host keys bound into the session (session-bind@openssh.com). With ProxyJump there was no socket to find.

    Rules. Use ProxyJump. If a workflow truly needs a key on a remote machine (pushing to GitHub from a login node), prefer a separate deploy key there (section 13) over forwarding; if you must forward, forward a constrained key, add ssh-add -c so every use asks you, and never put ForwardAgent yes under Host *. On the server, AllowAgentForwarding no on a bastion is reasonable when everyone uses ProxyJump (it was enabled here to record the attack).

    Recorded log: root on the bastion with a forwarded agent
    Agent locking and server-side fixes (10.0, 10.5)
    • Agent locking. ssh-add -x locks the agent with a password. 10.5 fixed a bug where a locked agent refused the session-bind messages that identify forwarded use, so operations meant to be local-only (adding PKCS#11 tokens, using destination-restricted keys) could be done remotely (10.5 release notes).
    • Server side. 10.0 fixed DisableForwarding, which had failed to disable agent and X11 forwarding.
    Predict, then reveal: with ProxyJump, can a malicious bastion do anything at all?
    It cannot read or alter the node session (encrypted end to end, and the node's host key is checked by your laptop), cannot use your keys, and cannot replay your signature (bound to the node session). It can refuse to relay, delay traffic, see when and how much you send, and see which node you asked for. If your laptop accepts the node's host key blindly (StrictHostKeyChecking no), the bastion could itself pretend to be the node, which is why host key checking still matters behind a bastion.

    7. Multiplexing: one login, many commands

    Every ssh, scp, rsync -e ssh, git pull and every VS Code helper starts from zero: TCP, key exchange, authentication, through the bastion and then again to the node, plus a two-factor prompt if the cluster has one. Connection multiplexing keeps the first connection (the master) open and lets later clients ask it, over a local Unix socket, for a new channel on the already-authenticated connection.

    Host gpu-node-* bastion
        ControlMaster auto            # use a master if one exists, otherwise become one
        ControlPath ~/.ssh/cm/%C      # where the socket lives; %C hashes local host, host, port, user and jump host
        ControlPersist 4h             # keep the master in the background after the first session ends

    Predict: ten ssh gpu-node-01 true in a row through a bastion 40 ms away; how much faster is the multiplexed lane by the tenth command?

    1. The first command becomes the master. A full login to the bastion and a second one to the node inside it, 821 ms with 40 ms added between laptop and bastion; the connection stays open behind a control socket on the laptop.
    2. The next command is one channel. A new ssh gpu-node-01 true finds the socket and asks the master for a channel: one round trip to the bastion and back, 114 ms (median of nine).
    3. Many clients, one connection. A shell, an rsync and a git pull each get their own channel on the same authenticated pipe (illustrative names).
    4. Ten commands, to scale. Each bar is one recorded run of ssh gpu-node-01 true: fresh logins every time against one master and nine reuses. After the first login, each command is one channel open on the master: 850 ms becomes 114 ms, 7.5 times faster.
    5. One master, one fate. ssh -O exit stops the master, and every session riding it ends at once: a session running sleep 20 ended with exit status 255 after 18 ms.

    Ten commands: 8.4 s fresh against 1.9 s multiplexed. A reused channel needs one round trip to the bastion and back for the channel open and request (the node hop is inside the cluster), against roughly eight per hop for a login (section 1). On a cluster with two-factor login it also means one prompt instead of one per command. ssh -O check host says whether a master is running; -O exit stops it; -O conninfo and -O channels are new in 10.3 (the negotiated algorithms and traffic, and the open channels).

    What it costs and how it fails

    • One master, one fate. When the master dies, every session on it dies at once. Recorded in Fig. 7, step 5. A laptop that sleeps and wakes on another network often leaves a master that looks alive but is not: -O check, then -O exit, or a short ServerAliveInterval (section 9) so it notices.
    • The socket is a key. Anyone who can open the control socket can open sessions as you without authenticating. Keep ControlPath in a directory only you can read (mkdir -m 700 ~/.ssh/cm); never in /tmp on a shared machine.
    • Authentication happens once, so a revoked key or an expired certificate does not end a master already running; ControlPersist bounds how long that lasts.
    • Bandwidth is shared. One TCP connection carries everything: a large rsync on the master slows your interactive shell, and one connection's congestion window caps total throughput. For bulk copies a separate connection (-o ControlMaster=no -o ControlPath=none) can be faster.
    Socket path length, scp and sftp since 10.0, and the 10.1 ControlPersist bug
    • Socket path length. A Unix socket path is limited (108 bytes on Linux, unix(7); 104 on macOS, sun_path[104] in its sys/un.h). %C is a fixed 40-character hash, which is why it is preferred to the older %r@%h:%p pattern. The lab hit the limit: its working directory alone was 120 characters, so it used the relative path ControlPath cm/%C.
    • Since 10.0, scp and sftp pass ControlMaster no: they use an existing master but no longer silently create one (10.0 release notes). 10.2 fixed a 10.1 bug that made sessions unusable with ControlPersist active, so avoid 10.1 with multiplexing.
    Recorded logs: -vvv of a reuse, -O conninfo, -O channels, -O exit
    Predict, then reveal: you changed User in your config for a host, but ssh host whoami still prints the old name. Why?
    A master from before the change is still running and serving the request: the new client never authenticated. ssh -O exit host and try again. The same trap catches changed forwarding options and agent forwarding: options of the original master apply.

    8. Port forwarding, tunnels and notebooks

    The notebook, TensorBoard or MLflow you want runs on a node your browser cannot reach. SSH carries TCP connections through its encrypted pipe as channels, in three directions. The flag says which end listens: -L and -D listen on the laptop, -R on the server. Fig. 8 steps through each forward as recorded on the lab.

    1. -L to the notebook through the bastion. One command, ssh -N -L 30988:127.0.0.1:8888 gpu-node-01 (-N: no remote command, just forward; add -f to go to the background): the laptop listens on 30988 (IPv4 and IPv6) and each browser connection becomes a direct-tcpip channel to 127.0.0.1:8888 as seen from the node. With the token the notebook accepted it; without, it answered 403.
    2. -L to a Unix socket. The same forward to a socket in a private directory, -L 30986:/home/dev/.nb/nb.sock, which other users of the node cannot open.
    3. -D: one SOCKS proxy. ssh -N -D 30989 bastion reached the notebook bound to all interfaces on gpu-node-01:8889 by name, because the bastion resolved it (--socks5-hostname). Plain --socks5 failed with "Could not resolve host", and the loopback-bound notebook on 8888 was unreachable, since the proxy connects from the bastion.
    4. -R: the other way. -R 30991:127.0.0.1:30990 opened a port on the bastion's loopback that leads back to the laptop ("served from the laptop"); GatewayPorts no kept it off the network.
    5. Port already taken: a warning, not an error. With only 127.0.0.1:30985 taken, the IPv6 listener succeeded and even ExitOnForwardFailure let the session run, so http://127.0.0.1:30985 reached the other program; with both taken, it exited 255.
    • -D: resolve names on the far side. --socks5-hostname (or the URL scheme socks5h://, as in ALL_PROXY=socks5h://127.0.0.1:30989) sends the name to the bastion, which knows gpu-node-01; plain --socks5 resolves on the laptop and fails. And the proxy connects from the bastion, so a service bound to the node's loopback is unreachable through it; use -L to the node for that one.
    • -R: the forwarded port opened on the bastion's loopback only, because the server's GatewayPorts defaults to no. Setting it to yes would expose your laptop's service to the whole network behind the bastion.
    • Forwards fail silently. By default a forward that cannot listen is a warning and the session carries on, so a script believes its tunnel is up. With ExitOnForwardFailure yes it exits 255. Recorded subtlety: -L 30985:... with no bind address listens on localhost in both IPv4 and IPv6; when only 127.0.0.1:30985 was taken, the IPv6 listener on [::1]:30985 still succeeded, so even ExitOnForwardFailure was satisfied, and http://127.0.0.1:30985 reached the other program. Bind explicitly (-L 127.0.0.1:30985:...) and pick ports nobody else uses: deriving the port from your user id (PORT=$((10000 + $(id -u) % 10000))) avoids collisions on shared nodes.
    FlagListens onConnects toUse
    -L 30988:127.0.0.1:8888your laptop, port 30988127.0.0.1:8888 as seen from the servera notebook or dashboard on the node in your browser
    -L 30986:/home/dev/.nb/nb.sockyour laptopa Unix socket on the serverthe safest way to serve a notebook (below)
    -D 30989your laptop: a SOCKS5 proxywhatever each request names, from the serverbrowse every internal service (Grafana, MLflow, Ray dashboard) with one tunnel
    -R 30991:127.0.0.1:30990the server, port 30991your laptop's 127.0.0.1:30990let the cluster reach something on your laptop (a licence server, a local API)

    Who else can reach your notebook?

    The node ran the same notebook three ways: bound to loopback 127.0.0.1:8888, bound to all interfaces 0.0.0.0:8889, and on a Unix socket inside ~/.nb (mode 700). Then another user on the same node (alice) and another node tried to connect. Predict which of the three alice reaches.

    Loopback keeps other machines out, not other users of the same node.
    Correction to the old page: loopback is not private to you
    The old page said to bind to 127.0.0.1 "or any other user on that node reaches your kernel". Binding to 127.0.0.1 keeps other machines out (the second node was refused), but every user on the same node shares its loopback: alice reached the loopback-bound notebook and, with the token, would have run code as dev. What protects you on a shared login or compute node is the token (Jupyter's default; never disable it) or, better, a Unix socket in a directory only you can enter: alice got Permission denied. Jupyter Server can listen on a Unix socket (--ServerApp.sock, created with mode 0600 by default, Jupyter Server config), and ssh -L port:/path/to/socket forwards straight to it (recorded: fwd_L_unix).
    Recorded logs: -L, -L to a socket, -D, -R, port taken
    Escape sequences, Kubernetes, and server-side controls
    • Escape sequences at the start of a line in an interactive session: ~C opens a command line to add or cancel forwards, ~. kills a frozen session, ~I (10.3) prints connection information, ~? lists them.
    • Kubernetes. kubectl port-forward pod/nb 8888:8888 is the same idea through the API server (Kubernetes docs).
    • Server controls: AllowTcpForwarding, PermitOpen (which destinations), PermitListen (which -R ports), AllowStreamLocalForwarding, and per-key restrict or permitopen=. 10.4 and 10.5 fixed cases where DisableForwarding and restrict did not cover tunnel forwarding, which is off by default.
    Predict, then reveal: you run ssh -L 8888:localhost:8888 gpu-node-01 and the browser shows a different notebook from the one you started. How?
    Something else on your laptop was already listening on 8888 (another tunnel, a local Jupyter), so ssh's listener failed with only a warning and the browser reached the other program; or the address family trap above. Check with lsof -nP -iTCP:8888 -sTCP:LISTEN, use a unique port, bind 127.0.0.1 explicitly, and set ExitOnForwardFailure yes.

    9. Keeping sessions alive, and noticing when they are dead

    A VPN, a NAT gateway or a firewall between you and the cluster forgets idle connections after a few minutes (AWS's NAT gateway after 350 seconds, as recorded on Networking foundations); a laptop sleeps; a server freezes. TCP alone will not tell you: with nothing to send, a dead connection looks exactly like a quiet one, and your terminal just hangs. Recorded: a session to gpu-node-01; three seconds in, the bastion was frozen (docker pause), so packets vanished without any refusal, as with a dead VPN.

    • ServerAliveInterval 30 with ServerAliveCountMax 3 (client; not TCPKeepAlive, whose kernel probes start only after 2 hours idle on Linux): after 30 s of silence ssh sends a request inside the encrypted connection and expects an answer; after 3 unanswered it disconnects (about 90 s). The probes also keep NAT and firewall state alive. Recorded with 2 and 2: exit after 5.0 s. Without it (the default is 0, off): still hanging after 30 s, when the script killed it.
    • Keepalives do not keep a job alive. When the connection dies, the shell and whatever runs in its foreground get a hangup. Run long work as a batch job (sbatch), and keep your interactive orchestration in tmux on the login node (section 13).
    With SSH-level keepalives the client gave up 5.0 s after the path died; without them it was still hanging at 30 s.
    TCPKeepAlive, and the server-side timers
    • TCPKeepAlive (on by default) asks the kernel for TCP keepalives, which on Linux start only after 2 hours idle (derived on Networking foundations: 7,200 s, then 9 probes 75 s apart). It is spoofable, does not go through the SSH layer, and is far too slow for a VPN that drops flows in minutes; ssh_config(5) itself points to ServerAliveInterval as the more robust mechanism.
    • ClientAliveInterval is the server's mirror image (default 0, recorded in sshd -T): it reaps sessions whose client vanished. ChannelTimeout and UnusedConnectionTimeout (both none by default) close idle channels or connections without channels.
    Recorded log: the frozen bastion, with and without keepalives

    10. Moving files: scp, sftp, rsync, tar

    All of these run over an SSH session channel; they differ in how many round trips each file costs and whether they can resume. Recorded through the bastion with 40 ms added (the same link as section 7), copying to gpu-node-01. Predict: how much slower is scp -r than rsync for 1,000 small files?

    • Many small files: scp -r took 193.3 s for 1,000 files of 4 KiB (one run), rsync -a 1.6 s, and tar -cf - small | ssh node 'tar -xf -' 1.3 s (medians of 3). Since OpenSSH 9.0, scp speaks the SFTP protocol underneath (9.0 release notes), which pays several request round trips per file; rsync and tar stream.
    • One large file (64 MiB): scp 4.5 s, rsync -a 4.1 s: similar, both bounded by one encrypted TCP stream.
    • Resuming: an rsync --partial of the 64 MiB file was interrupted after 1.5 s, leaving 10,321,920 bytes on the node; rerunning it matched 10,320,136 of them and sent only the rest, in 4.4 s against 4.1 s for a full copy. On this fast link resuming saved bytes, not time (rsync still reads and checksums both sides); it pays off on slow, metered or flaky links, which is exactly when checkpoints get interrupted. Use rsync -avhP --partial (-P is --partial --progress). The laptop's rsync was macOS's openrsync (protocol 29); the node ran rsync 3.5.1.
    • sshfs mounts a remote directory over SFTP: handy for editing, slow for anything with many small reads (each is a round trip), so never point a data loader at it. For editing remote code, VS Code Remote-SSH runs the editor's server on the node instead (section 13). Moving big checkpoints between storage tiers is on Storage and data movement.
    Per-file round trips dominate small files: scp -r took minutes where rsync and a tar pipe took about a second.
    Legacy scp bugs, and the state of sshfs (with a correction)
    • Legacy scp (scp -O) asks the remote shell to expand file names, which has produced a series of bugs; 10.3 fixed one where legacy-mode downloads as root kept setuid bits, and 10.4 fixed two cases where a malicious server could make sftp or a remote-to-remote scp write outside the intended directory (release notes).
    • sshfs is maintained for fixes but has "no active, regular contributors" (sshfs README; latest release 3.7.6, May 2026).
    Correction to the old page
    "sshfs is effectively unmaintained": its README says the maintainer still applies pull requests and makes regular releases, with no development beyond high-impact issues.

    11. Post-quantum SSH

    A large enough quantum computer would break the elliptic-curve Diffie-Hellman behind every key exchange in section 1. None exists yet; OpenSSH's own estimate quotes "5-20 years, with many observers expecting them to arrive in the mid-2030s" (OpenSSH, Post-Quantum Cryptography). The danger is already real because of store now, decrypt later: someone who records your session today can decrypt it once they have such a machine. Signatures are different: a forged signature needs the quantum computer at the moment of the login, so there is no urgency for host and user keys yet.

    Already the default. mlkem768x25519-sha256 (ML-KEM-768, NIST FIPS 203, plus X25519) has been OpenSSH's default since 10.0 (9 April 2025), "considerably faster than the previous default". That previous default, the hybrid sntrup761x25519-sha512@openssh.com, arrived in 9.0 (April 2022) and made SSH one of the first mainstream protocols with post-quantum key exchange on by default. It is specified in RFC 10042 (August 2026, Informational).

    What it cost here (section 1, to scale): 2512 key-exchange bytes against 240, and no login time worth measuring on a link where a round trip costs more than the arithmetic (sntrup761 took 67 ms against ML-KEM's 61 ms, consistent with OpenSSH calling ML-KEM faster). Unlike TLS, where large post-quantum certificates threaten handshake size (TLS and certificates, section 8), SSH sends one host key and one signature, so even future post-quantum signatures add little.

    The warning, recorded against gpu-node-02, an OpenSSH 9.7p1 server configured to offer only classic key exchange, as an old login node would. Since 10.1 the client warns when a connection uses a non-post-quantum key exchange; WarnWeakCrypto controls it, on by default:

    
    

    The fix is to upgrade the server or re-enable its post-quantum algorithms (9.0 and later support sntrup761, 9.9 and later ML-KEM). If you cannot, silence it for that host only, as the OpenSSH page recommends: Match host gpu-node-02 then WarnWeakCrypto no-pq-kex. Do not hand-write KexAlgorithms or Ciphers lists copied from old hardening guides: frozen lists are how servers end up without the post-quantum default, exactly as this node was configured.

    The timeline, with dates
    WhenWhat
    OpenSSH 9.0, 8 April 2022Hybrid sntrup761x25519-sha512@openssh.com (Streamlined NTRU Prime plus X25519) becomes the default.
    OpenSSH 9.9, 19 September 2024Adds mlkem768x25519-sha256.
    OpenSSH 10.0, 9 April 2025mlkem768x25519-sha256 becomes the default.
    OpenSSH 10.1, 6 October 2025The client warns on non-post-quantum key exchange (WarnWeakCrypto).
    April 2026RFC 9941 documents sntrup761x25519-sha512 (Informational).
    OpenSSH 10.4, 6 July 2026Experimental composite signature mldsa44-ed25519 (ML-DSA-44 plus Ed25519), off by default; keys with ssh-keygen -t mldsa44-ed25519.
    August 2026RFC 10042 specifies mlkem768x25519-sha256, mlkem768nistp256-sha256 and mlkem1024nistp384-sha384 (Informational).

    Dates from the OpenSSH release notes and the RFC Editor.

    Correction to the old page
    "The IETF hybrid key exchange draft is in the RFC Editor queue rather than published": it was published as RFC 10042 in August 2026. The sntrup761 method is RFC 9941 (April 2026).

    12. Security: the bugs worth understanding, and a baseline

    regreSSHion (CVE-2024-6387): keys do not protect you from a pre-authentication bug

    Disclosed by Qualys on 1 July 2024 (advisory). If a client has not authenticated within LoginGraceTime (120 s by default), sshd gets a SIGALRM whose handler logs a message; on glibc-based Linux, syslog() calls malloc() and free(), which are not safe inside a signal handler, so an alarm arriving in the middle of an allocation leaves the heap inconsistent, and a patient attacker turns that into code execution as root, before authentication. Fixed in 9.8 (1 July 2024); the stop-gap if you could not upgrade was LoginGraceTime 0, trading the exploit for a denial of service. The lesson: an internet-facing sshd is attack surface no matter how good your keys are.

    regreSSHion: affected versions, how hard, and a correction

    A regression of CVE-2006-5051, reintroduced in October 2020 (OpenSSH 8.5p1). Affected: portable OpenSSH below 4.4p1 (unless patched) and 8.5p1 up to but not including 9.8p1. OpenBSD was not vulnerable (its handler uses syslog_r()). How hard: Qualys needed about 10,000 tries on average to win the race; on 32-bit Linux with ASLR that took about 6 to 8 hours on average (9.8 release notes); 64-bit exploitation was "believed to be possible" but not demonstrated at disclosure.

    Correction to the old page
    It said "roughly one attempt in ten thousand ... glibc-Linux only". The advisory's figure is about 10,000 tries on average to win the race (6 to 8 hours on 32-bit glibc with ASLR); exploitation was shown on glibc Linux, other C libraries were not examined rather than ruled out, and OpenBSD is not vulnerable.

    Terrapin (CVE-2023-48795): an attack on the protocol itself

    Disclosed 18 December 2023 (terrapin-attack.com). An on-path attacker could tamper with the message sequence across the start of encryption without the integrity check noticing. The fix, strict key exchange in OpenSSH 9.6, aborts on any unexpected handshake message and resets sequence numbers after each key exchange, and only works when both sides support it. You can see it in the recorded handshake: the client lists kex-strict-c-v00@openssh.com in its KEXINIT, and the log says will use strict KEX ordering and resetting send seqnr 3.

    Terrapin: which ciphers, what it did to OpenSSH, how widespread
    The attacker inserts an ignorable message during the plaintext handshake and deletes one right after encryption starts; sequence numbers still line up, so the integrity check passes. It works against chacha20-poly1305@openssh.com and against CBC ciphers with encrypt-then-MAC MACs; AES-GCM is not affected. Against OpenSSH the practical impact was small: deleting the EXT_INFO message, which disabled some keystroke-timing protections (OpenSSH 9.6 notes); some other implementations were hurt more. The researchers found at least 77% of internet SSH servers supported an exploitable mode at disclosure.

    The version banner is not the patch level

    
    

    A scanner reading OpenSSH_9.7 would flag this node for regreSSHion; Alpine's package 9.7_p1-r4 and later carries the fix, and -r5 also fixes the two 2025 CVEs (Alpine APKBUILD secfixes). Distributions backport; check the package, not the banner.

    PerSourcePenalties: rate limiting built in, and how it locks out a bastion

    Since OpenSSH 9.8, sshd penalises source addresses that fail authentication, connect without authenticating, or crash it, and refuses them for a while, with no log-parsing daemon such as fail2ban. Recorded on gpu-node-01 with the default policy: six failed logins one second apart, all arriving from the bastion's address.

    Attempts 5 and 6 were dropped before authentication. Note who got blocked: the bastion. Every user behind it shares that source address, so one broken script locks out the whole team. On nodes reached through a bastion or a NAT gateway, list those addresses in PerSourcePenaltyExemptList (and rate-limit on the bastion instead), or the protection becomes a self-inflicted outage.

    After four failures the node refused the bastion's address for 16.563 s: every user behind the bastion was locked out together.
    Recorded log: the six attempts, the node's log, the default policy
    A hardening baseline for a cluster's sshd
    • PasswordAuthentication no and KbdInteractiveAuthentication no (unless your two-factor login uses keyboard-interactive), PermitRootLogin no, AllowGroups for who may log in at all.
    • Keep the defaults for algorithms (recorded sshd -T in section 2): post-quantum first, ChaCha20-Poly1305 then AES-GCM; no CBC, no DSA, no finite-field Diffie-Hellman in sshd's defaults since 10.0. (The old page said non-EtM MACs are off by default: the recorded 10.5 default list still contains them, after the encrypt-then-MAC ones; with ChaCha20-Poly1305 or AES-GCM no separate MAC is used anyway.)
    • MaxAuthTries (6), MaxStartups (10:30:100: start refusing 30% of unauthenticated connections at 10, all at 100), LoginGraceTime (120 s), PerSourcePenalties (on): defaults recorded above; tighten LoginGraceTime and MaxAuthTries on the internet-facing host.
    • Forwarding off by default and enabled per Match Group; AllowAgentForwarding no on the bastion if people use ProxyJump.
    • User certificates with short lifetimes and host certificates (section 4); a KRL for emergencies.
    • Moving sshd to port 2222 reduces log noise from scanners; it is not a security control (reasoning, not a measured claim).

    Not exposing port 22 at all is the strongest move: AWS Session Manager (no inbound port, IAM-authorised, audited; a ProxyCommand keeps ssh, -J and rsync working: AWS docs), a WireGuard or Tailscale overlay network (devices authenticate before any SSH packet flows), or Teleport (a certificate-issuing proxy with single sign-on and session recording). On a university cluster you rarely choose; ProxyJump plus ControlMaster is what makes a VPN plus two-factor login bearable.

    Fixes since 2025, version by version
    Fixed inWhat
    9.9p2 (2025-02-18)CVE-2025-26465: client impersonation with VerifyHostKeyDNS on (6.8p1 to 9.9p1). CVE-2025-26466: pre-authentication memory and CPU exhaustion through PING packets (9.5p1 to 9.9p1). Both found by Qualys.
    10.0 (2025-04-09)DisableForwarding did not disable agent and X11 forwarding. Also: authentication code moved into its own sshd-auth binary, so the pre-authentication attack surface has a separate address space.
    10.1 (2025-10-06)CVE-2025-61984: control characters in user names and ProxyCommand (section 5).
    10.3 (2026-04-02)Shell metacharacters in user names validated too late for some %u uses; a certificate-principal matching bug with commas (authorized_keys path only); legacy scp setuid bits; PubkeyAcceptedAlgorithms not fully applied to ECDSA.
    10.4 (2026-07-06)sftp and remote-to-remote scp writing outside the target directory; DisableForwarding did not override PermitTunnel; a client use-after-free if the server changes its host key during rekeying; minimum authentication delay not always enforced.
    10.5 (2026-08-11)Agent locking against session-bind (section 6); a client use-after-free with multiplexed remote forwards; restrict now also covers tunnel forwarding.

    From the OpenSSH release notes and the CVE record for CVE-2025-61984. 10.5's notes say the team is "making more frequent releases" because many recent reports came from AI-assisted research and bugs found that way were being independently rediscovered by others: patch cadence matters more than it used to.

    13. Cluster workflows

    A config that encodes all of the above

    Click a line to see what it does and which recorded result backs it. Host names are placeholders; the lab's own config is src/lab/laptop.conf.

    Lines explained: HostName and User, a hardware-key IdentityFile for the internet-facing hop, ControlMaster, ControlPath and ControlPersist per hop, %h expansion, ProxyJump in two hops, a separate UserKnownHostsFile with accept-new for nodes, then under Host *: IdentitiesOnly, AddKeysToAgent, ServerAliveInterval, ForwardAgent no, ExitOnForwardFailure, HashKnownHosts.

    A notebook on a Slurm compute node

    Jobs, steps and sbatch are on Slurm; what login and compute nodes are, on Cluster anatomy. The SSH part:

    # inside the batch job (sbatch), on the compute node
    PORT=$((10000 + $(id -u) % 10000))
    mkdir -m 700 -p ~/.nb
    jupyter lab --no-browser --ServerApp.sock=$HOME/.nb/nb-$SLURM_JOB_ID.sock &
    echo "on your laptop: ssh -N -L 127.0.0.1:$PORT:$HOME/.nb/nb-$SLURM_JOB_ID.sock $(hostname)"
    # on the laptop (ProxyJump in the config does the hops)
    ssh -N -o ExitOnForwardFailure=yes -L 127.0.0.1:8888:/home/you/.nb/nb-123.sock gpu-node-07

    The pieces: a Unix socket in a private directory so other users on the node cannot reach the kernel (section 8), a port derived from your user id so you do not collide with colleagues, the exact command printed into the job's log so you can paste it, ExitOnForwardFailure so a taken port is an error. If the site does not allow SSH to compute nodes at all, use the scheduler's own route (Open OnDemand, or srun with a port forward through the login node).

    Getting onto a node where your job runs

    • srun --overlap --jobid=ID --pty bash starts a shell as a new step inside your running job; --overlap lets it share the job's resources with the steps already running (srun).
    • Plain ssh to the node works where the site runs pam_slurm_adopt: it refuses SSH to nodes where you have no running job and "adopts" your connection into the job's external step, so its processes are accounted and cleaned up with the job (pam_slurm_adopt).
    • Keep work in batch jobs. An interactive srun --pty dies with your connection. Run tmux on the login node for the shell you orchestrate from, so a closed laptop or dropped VPN loses nothing; avoid leaving it on compute nodes, where job cleanup kills stray processes.

    Editors, Git and containers

    • VS Code Remote-SSH installs a server on the remote and runs extensions there. It needs glibc 2.28 or later and libstdc++ 3.4.25 on the remote (VS Code docs), which excludes CentOS 7 era login nodes. It opens several channels, so pair it with ControlMaster and a long ControlPersist to avoid repeated two-factor prompts.
    • GitHub from a cluster. Use a per-repository deploy key (read-only by default) on the cluster rather than your personal key or a forwarded agent: a compromised login node then exposes one repository (GitHub deploy keys). If outbound port 22 is blocked: Host github.com, Hostname ssh.github.com, Port 443, User git (GitHub docs).
    • Containers: do not run sshd inside a container to get a shell; use docker exec, kubectl exec or apptainer shell, and kubectl port-forward instead of -L (containers themselves: Containers and isolation). This page's lab runs sshd in containers only because SSH is the subject.
    Signing Git commits with SSH keys
    • Signing commits with SSH keys: git config gpg.format ssh and user.signingkey; GitHub has verified SSH signatures since 23 August 2022 (GitHub changelog). An -sk key makes every signature need a touch.

    14. Debugging, in order

    Most SSH failures are found by asking, in order: did TCP connect, did the key exchange agree, did the host key check pass, which keys were offered and why were they refused, and did the channel or forward open. ssh -v answers the first four from your side; the server log answers the "why" of authentication. Every message below was recorded in the lab; the Error decoder tab starts from the message and shows the log.

    Walk the layers from the bottom: the first stage that fails names the fix.
    You seeFirst commandUsual cause and fix
    Connection timed out / Connection refusedssh -v (the Connecting to line), nc -vz host 22Wrong address or port, firewall, no route (a compute node without ProxyJump), sshd not running.
    Connection closed by ... port 22 right after connecting, or Connection reset before the bannerserver logPerSourcePenalties or MaxStartups refusing your address (section 12), TCP wrappers, a firewall.
    Unable to negotiate ... no matching key exchange methodssh -vv (both KEXINIT lists), ssh -Q kexAn old server or a hand-written algorithm list; upgrade, or enable one algorithm for that host only.
    WARNING: connection is not using a post-quantum key exchangessh -v | grep kex:Server without PQ key exchange (section 11).
    REMOTE HOST IDENTIFICATION HAS CHANGEDcompare the printed fingerprint out of bandRebuilt node or attack (section 3). Host certificates remove the routine case.
    Host key verification failed.ssh -v, ssh-keygen -F hostUnknown host under StrictHostKeyChecking yes or BatchMode, or a changed key.
    Permission denied (publickey).ssh -v (Offering lines), ssh -G host | grep identityfile, then the server logWrong key, wrong user, key not in authorized_keys, file permissions on ~/.ssh, or a certificate that is expired, for another principal, or revoked (section 4). The same message for a user that does not exist, so accounts cannot be enumerated.
    Too many authentication failuresssh -v, ssh -Z (10.5)Agent holds too many keys: IdentitiesOnly yes.
    stdio forwarding failed / channel 0: open failed: connect failedssh -v on the jump; can the bastion resolve and reach the node?Node down or renamed, DNS on the bastion, AllowTcpForwarding no or PermitOpen on the bastion.
    bind [127.0.0.1]:8888: Address already in uselsof -nP -iTCP:8888 -sTCP:LISTENPort taken; the session continues unless ExitOnForwardFailure yes (section 8).
    Terminal frozen, no error~. to kill itPath died silently: set ServerAliveInterval (section 9).
    Killed by signal 1. after a session through a jump hostnothingHarmless: printed by the ProxyJump helper when the main session ends and closes it; -q or LogLevel ERROR hides it.
    Old user, old options after editing the configssh -O check hostA multiplexing master predates the change: ssh -O exit host (section 7).

    Server side: sshd -T prints the effective configuration (with -C user=dev,host=...,addr=... to evaluate Match blocks), sshd -t checks the file before a reload, LogLevel VERBOSE logs key fingerprints and certificate IDs, and a second sshd -d -p 2222 runs one debug connection in the foreground without touching the real service.

    Reference

    Interview rehearsal: seven questions with answers

    Walk me through what happens when you type ssh gpu-node-01 through a bastion. The client reads its config, finds ProxyJump bastion, and starts a helper ssh -W gpu-node-01:22 bastion. That helper opens TCP to the bastion, exchanges version strings and KEXINIT lists, runs the key exchange (by default the hybrid ML-KEM-768 plus X25519), verifies the bastion's host key signature against known_hosts or a host CA, switches on encryption, authenticates with a key or certificate whose signature covers the session identifier, and opens a direct-tcpip channel to the node's port 22. Through that channel the main client runs a second, independent handshake and authentication with the node, opens a session channel and requests a shell. The bastion only relays ciphertext. About eight round trips per login, doubled by the hop, which is why ControlMaster matters.

    Why is agent forwarding dangerous, and what do you use instead? The remote sshd exposes a socket that forwards signing requests to your local agent. Anyone with root on that machine, or running as your user, can use it while you are connected to authenticate as you anywhere your key is accepted; your private key never leaves your laptop but it does not need to. Use ProxyJump, which relays an encrypted stream and never gives the bastion signing ability. If forwarding is unavoidable, use destination-constrained keys (ssh-add -h) and confirmation (ssh-add -c).

    How does SSH prevent a man in the middle, and where is it weak? The server signs the key exchange hash with its host key, and the client checks that key against what it knows. The weak points are the first connection (trust on first use: the user must verify the fingerprint) and habituation to "host key changed" warnings on rebuilt machines. Host certificates fix both: the client trusts a CA key, and any properly signed host key for that name is accepted without a prompt. SSHFP records with DNSSEC are an alternative.

    What are SSH certificates and why would a company use them? A CA signs a user's public key together with a key ID, principals, a validity window, a serial and options. Servers trust the CA key instead of per-user authorized_keys. Onboarding and offboarding become CA policy, certificates expire on their own (hours), logs name the certificate, and a KRL handles emergencies. Host certificates do the same for server identity. The CA key becomes the crown jewel, usually behind single sign-on (Vault, Teleport).

    Your notebook tunnel works but a colleague says they can reach your notebook too. How? They are on the same node: loopback is shared by all local users, so binding to 127.0.0.1 does not isolate you from them, only from other machines. Or the notebook was bound to 0.0.0.0. Keep a token, and preferably serve on a Unix socket in a mode-700 directory and forward to it with -L port:/path/socket.

    What does post-quantum key exchange protect against in SSH today, and what does it not? It protects recorded sessions against future decryption (store now, decrypt later), which is why OpenSSH made a hybrid the default in 2022 and ML-KEM in 2025. It does not protect authentication against a future quantum attacker, but that attack would have to happen live, so there is time; experimental ML-DSA composite signatures arrived in 10.4. The hybrid construction means it is no weaker than X25519 even if ML-KEM were broken.

    Explain regreSSHion in two minutes. An async-signal-safety bug in sshd's login-grace-time alarm handler, which called syslog (and through it malloc) from a signal handler on glibc Linux. Interrupting an allocation at the right moment corrupts the heap; winning the race, which took about 10,000 tries on average, led to root code execution before authentication. A 2006 bug reintroduced in 8.5p1 (2020), fixed in 9.8 (July 2024). Mitigation without patching: LoginGraceTime 0. Lesson: pre-auth bugs bypass key-only authentication, so limit exposure of sshd.

    Recent OpenSSH changes worth knowing, 9.8 to 10.5
    Version and dateChange that affects you
    9.8 (2024-07-01)regreSSHion fixed; PerSourcePenalties on by default; sshd split into listener and per-session binaries.
    9.9 (2024-09-19)mlkem768x25519-sha256 added.
    10.0 (2025-04-09)ML-KEM hybrid default; DSA removed; finite-field DH out of sshd defaults; sshd-auth binary; scp and sftp no longer create multiplexing masters; version string OpenSSH_10.0 confuses naive OpenSSH_1* matching.
    10.1 (2025-10-06)Warning for non-PQ key exchange (WarnWeakCrypto); agent sockets under ~/.ssh/agent; ssh-add expires certificates; server logs refused certificates in detail; RefuseConnection config option; XMSS keys removed.
    10.2 (2025-10-10)Bug-fix release for the ControlPersist breakage in 10.1.
    10.3 (2026-04-02)Agent forwarding uses the IANA names of the agent standard; ~I, -O conninfo, -O channels; -J name validation; empty-principal certificate change; invaliduser penalty.
    RFC 9987 (May 2026)The SSH agent protocol, Standards Track.
    10.4 (2026-07-06)Experimental mldsa44-ed25519 signatures; stricter transport during rekey; sshd -G prints mixed-case names.
    RFC 10042 (August 2026)ML-KEM hybrid key exchange for SSH.
    10.5 (2026-08-11)ssh -Z; low-friction FIDO keys tried first; requires ECC with NIST P-521 in libcrypto when built (matters for custom container builds); agent-lock fix.

    All from the OpenSSH release notes and the RFC Editor, checked 5 October 2026.

    Recorded and checked on 5 October 2026. Lab scripts, raw outputs and the build are in this page's src/ folder in the knowledge base repository.