Skip to content

fix(ssh): honor configured host trust with accept-new by default - #120

Merged
Zorlin merged 6 commits into
mainfrom
fix/openssh-host-trust
Nov 6, 2026
Merged

Zorlin merged 6 commits into
mainfrom
fix/openssh-host-trust

Conversation

@Zorlin

@Zorlin Zorlin commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The native SSH handshake previously accepted every server key, including changed keys. Verify the server against existing OpenSSH trust files before authentication or remote execution.

The default behavior is accept-new: enroll unknown hosts, accept their stored keys on repeat connections, and reject changed keys. Explicit SSH config controls trust policy. Keep russh SSH/SFTP and existing native authentication, including agent key-comment selection.

  • Resolve the supported SSH config subset natively. Ordinary connections need neither ssh nor ssh-keygen. The pre-existing explicit agent-forwarding command path retains its ssh requirement.
  • Read/write existing user/global known_hosts files, including patterns, negation, hashing, aliases, multiple keys, certificate authorities, revoked markers, and KRLs. No Jetpack-specific trust database or key cache.
  • Serialize enrollment and revalidate every checked hostname/IP under the destination lock. Under explicit no/off, any tolerated changed key prevents all enrollment and disables password authentication and agent forwarding.
  • Respect explicit Jetpack user/port settings over SSH config, while allowing configured values to replace implicit defaults.
  • Include controller CA roots in the container for the existing HTTPS client. No OpenSSH package is added.

Closes #110. Closes #121. Closes #122.

Validation

  • Full local suite: 937 passed.
  • 22 SSH/config/trust tests, including real native SSH/SFTP, uploads/downloads, reconnects, rotation rejection before credentials, and certificate handshakes.
  • Native lifecycle with an empty PATH proves ssh and ssh-keygen are unavailable while commands/SFTP/trust still work.
  • OpenSSH interoperability in both directions; configuration comparison and OpenSSH-generated KRL fixtures covering keys, fingerprints and certificate revocations.
  • Changed hostname + unknown IP + explicit no regression, reversed hostname/IP order, and a competing enrollment between initial and locked validation. Stored records remain byte-for-byte unchanged.
  • Host certificate principal/type/time/CA restrictions, strict unknown-host policy, configured stores/aliases/ports, hashed lookup, negated patterns and malformed records.
  • Formatting, diff checks, generated-reference check, and clippy all-targets pass; clippy reports the existing 174 test-target warnings and no new connection warnings.
  • All final-head CI checks passed before merge. No infrastructure hosts or operator trust files were used in testing.

Supported configuration and limits

Read ~/.ssh/config then /etc/ssh/ssh_config, with first applicable value winning. A custom config replaces those sources. Supported rules: Host patterns/negation, Include with */? globs, and Match all/final/host/originalhost/user/localuser. Explicit Jetpack settings retain precedence. Native username matches and certificate principals are case-sensitive.

Supported settings: HostName, User, Port, StrictHostKeyChecking, HostKeyAlias, UserKnownHostsFile, GlobalKnownHostsFile, HashKnownHosts, CheckHostIP, explicit HostKeyAlgorithms lists, and RevokedHostKeys. Paths support quoting, ~/, environment expansion and %%/%d/%h/%n/%p/%r/%u tokens. Relative trust paths use the current working directory; relative Includes use ~/.ssh or /etc/ssh according to their source. Include depth is capped at 16.

The client is noninteractive: ask rejects unknown hosts. no/off permits changed keys without enrollment or credential/agent exposure. Unsupported Match criteria, DNS canonicalization, ProxyCommand, ProxyJump, KnownHostsCommand, VerifyHostKeyDNS, explicit CASignatureAlgorithms/RequiredRSASize restrictions, and HostKeyAlgorithms list modifiers fail explicitly. These are Jetpack integration limits, not fundamental russh restrictions. Identity selection remains controlled by Jetpack's existing native options. Unsupported path syntax and malformed/unsupported revocation formats fail closed.

Direct hashing dependencies already existed transitively; no new package versions enter the lockfile. Implementation details are recorded here; no standalone host-trust documentation page is added.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Deploying jetpack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 25dcf48
Status: ✅  Deploy successful!
Preview URL: https://43352a6c.jetpack-1ws.pages.dev
Branch Preview URL: https://fix-openssh-host-trust.jetpack-1ws.pages.dev

View logs

Recheck every hostname and IP under the enrollment lock using the same policy. Cover changed hostname/unknown IP in both orders and a competing enrollment between validation passes. Refs #122.
Resolve the documented SSH config subset and shared known_hosts/KRL formats natively. Keep helper executables confined to explicit agent forwarding, and prove native commands/SFTP/trust work with an empty PATH. Document unsupported integration and move handwritten docs outside generated reference output. Refs #121.
Keep username matches case-sensitive and reject host certificates without a matching principal. Verify certificate negotiation over a real native handshake before password authentication.
@Zorlin Zorlin closed this Nov 4, 2026
@Zorlin Zorlin reopened this Nov 4, 2026
@Zorlin
Zorlin merged commit aa815a7 into main Nov 6, 2026
28 of 32 checks passed
@Zorlin
Zorlin deleted the fix/openssh-host-trust branch November 6, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant