Accepting a host key on first connection creates risk because the client has no independent way to prove the server identity at that moment. If an attacker intercepts traffic, they can present a fake key, get added to known_hosts, and persistently intercept later sessions. That turns a temporary interception into a durable trust failure.
Why the first connection is the dangerous moment
Host key verification is meant to bind a server’s identity to a stable cryptographic key. On the first connection, that binding does not yet exist, so the client is deciding whether to trust a key without an established reference. That makes the first contact a trust-on-first-use event, which is convenient but inherently weaker than an already-verified trust relationship.
The risk is not that SSH is “broken”; the risk is that the client is asked to make a permanent trust decision before it has enough assurance to do so safely. If the wrong key is accepted, the mistake is not just temporary. It becomes part of the client’s local trust store and can shape every later session.
How a fake first key turns into persistent compromise
Accepting the presented key gives an attacker a chance to become the client’s remembered server. In a man-in-the-middle position, the attacker can relay, read, or alter traffic during that initial session, then cause the client to record the attacker’s key in known_hosts. Later, the legitimate server will appear “changed,” while the attacker’s key now looks familiar.
That persistence is what makes the risk worse than a one-off interception. The initial spoofed trust anchor can suppress warnings, normalize a hostile endpoint, and create a durable false identity for the host. If the client keeps connecting automatically or with minimal scrutiny, the attacker may retain an interception path long after the original network position has disappeared.
What makes the risk material in practice
Host key acceptance is a security decision about identity, not just a connection convenience. The first connection is the point where you are most vulnerable to network-level impersonation, DNS poisoning, rogue Wi-Fi, compromised jump paths, or any other condition that can place an attacker between client and server. Once the key is cached, the security model depends on later detection of change rather than first-time proof.
That is why first-contact verification matters more than many teams expect. A missed warning, a rushed manual acceptance, or an informal “just trust it this once” habit can convert a recoverable uncertainty into a long-lived trust failure. The danger grows when the connection is automated, used for administration, or allowed to unlock further privileged access.
Risk and Threat Considerations
The main risk is identity spoofing at the exact point where the client has no prior baseline. If an attacker can control or influence the network path during enrollment, they can capture the trust anchor and make later interception much easier to sustain.
Failure mechanism: A fake server key is accepted during first contact, written into known_hosts, and then treated as the legitimate endpoint on subsequent sessions.
Impact: The attacker can persist as a trusted endpoint, intercepting, redirecting, or observing later SSH traffic until the cached trust is corrected.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK addresses the attack surface, NIST SP 800-53 Rev 5 and CIS Controls v8 set the technical controls, and ISO/IEC 27001:2022 defines the regulatory obligations.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | IA-9 — Identification and Authentication (Non-Organizational Users) | SSH host-key trust depends on authenticating a remote system endpoint. |
| IA-5 — Authenticator Management | Host keys are long-lived authenticators whose lifecycle affects exposure. | |
| AC-17 — Remote Access | SSH is remote access, and first-connection trust directly affects remote-session risk. | |
| Recommendation — Require strong remote-system authentication before caching host trust. Manage host key issuance, rotation, and revocation as controlled authenticators. Gate remote SSH access on verified endpoint identity before use. | ||
| ISO/IEC 27001:2022 | A.5.17 — Authentication information | SSH host keys function as authentication information for endpoint identity. |
| A.8.24 — Use of cryptography | SSH host key verification relies on cryptographic trust in the server key. | |
| Recommendation — Protect and verify host-key material before it is accepted or stored. Use cryptographic verification procedures that confirm the server key out of band. | ||
| CIS Controls v8 | CIS-6 — Access Control Management | SSH trust decisions affect who and what may establish remote access. |
| Recommendation — Restrict SSH trust onboarding to verified, controlled administrative processes. | ||
| MITRE ATT&CK | T1557 — Adversary-in-the-Middle | First-connection host-key acceptance is exploitable by MITM interception. |
| Recommendation — Hunt for MITM conditions when host-key trust is established interactively. | ||
Practitioner Guidance
What to verify: Do not treat first connection prompts as routine. Verify the server key through an out-of-band channel, such as a trusted inventory, console access, or a separately authenticated fingerprint distribution process, before you accept it.
What good looks like: Teams should know how host keys are generated, published, rotated, and checked, and they should be able to explain what source of truth establishes the server identity. Where possible, pre-provision known_hosts entries or use controlled discovery so the client is not relying on blind first-use trust.
Practitioner takeaway: The real control is not “accept once and hope,” it is proving the server identity before the first trust anchor is written, because the first accepted key can outlive the network condition that made it dangerous.
Related resources from NHI Mgmt Group
- When does relying on SSH keys and host key verification create more operational risk than it removes?
- Why do hidden application identities create risk for identity-first security programmes?
- Why do fragmented key stores create so much security risk?
- Why do long-lived SSH public keys create security risk in large environments?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on September 27, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org