OpenSSH 8.9 adds support for destination‑constrained keys, a feature that restricts an ssh‑agent‑held private key to a set of explicitly listed hosts.
Destination‑constrained keys explained
When the -h option is used with ssh‑add, the client looks up the target host’s public key fingerprint in the local known_hosts file and passes that fingerprint to the agent as a constraint. The agent then records the association and, on each signing request, checks that the requested destination matches one of the stored fingerprints before producing a signature. In effect, the key can only be used for authentication to the hosts that were listed when it was added, and any attempt to sign for a different host is rejected by the agent.

Practical limits and required setup
The mechanism depends on a trustworthy known_hosts database; an unknown or outdated host key cannot be encoded as a constraint. Because the constraint is tied to host‑key fingerprints, key rotation or host‑key changes require updating the local known_hosts entries before re‑adding the constrained key. OpenSSH 8.9 does not apply constraints automatically—keys are unconstrained unless added with -h. Moreover, the feature works only when all participants—ssh‑agent, ssh‑add, the ssh client and the remote sshd—run versions that understand the new protocol extensions, otherwise the constraint is ignored.
Deploying with least‑privilege
Operators are encouraged to generate separate key pairs for distinct trust domains, load each with the minimal set of -h destinations, and keep their lifetimes short. Automation scripts should point at a dedicated agent socket rather than the default one, and SSH configurations can bind an identity file to a particular Host stanza to avoid accidental forwarding. When ForwardAgent is enabled, the constraint is the only control that limits what a remote host can request from the agent, so logging the host‑key fingerprint used for each constraint and auditing loaded keys are essential practices.
Why the change matters for teams that forward agents
Forwarding an ssh‑agent is a common pattern for jump‑host or bastion workflows, but it also opens a path for an attacker who compromises the intermediate host to harvest any keys that the agent is willing to sign for. Destination constraints close that gap by making the agent refuse signatures for hosts that were not explicitly approved when the key was added. This aligns the agent’s behavior with the principle of least privilege, allowing administrators to delegate a key to a bastion without exposing it to every downstream server. The limitation that constraints rely on host‑key fingerprints means that organizations with frequent host‑key rotation must incorporate known_hosts management into their CI/CD pipelines. Teams that already use host certificates benefit because only the CA key needs to be present locally for constraint creation. Overall, the feature gives security‑focused teams a usable, built‑in control that complements existing hardening measures such as disabling ForwardAgent where possible, using short‑lived keys, and enforcing authorized_keys options on the server side.
Cover: Victorgrigas · CC BY-SA 3.0 · Wikimedia Commons. Layout and headline text by Signal Titans.
Source: An SSH agent can hold a key without granting every destination · SSH agent restriction

Leave a Reply