Join our Newsletter — 33% off our NHI Course
Home› Glossary› Authentication, Authorisation & Trust› SSH Known Hosts File
Authentication, Authorisation & Trust

SSH Known Hosts File

← Back to Glossary
By NHI Mgmt Group Updated October 29, 2026 Domain: Authentication, Authorisation & Trust

The SSH Known Hosts File is a local file that stores fingerprints of SSH servers a client has previously seen. When a connection is made, SSH checks the server’s host key against this file to detect changed or unknown keys and reduce the risk of man-in-the-middle attacks.

What the SSH known_hosts file does

The known_hosts file is SSH’s local memory of server host keys. It helps the client decide whether the server it is reaching is the same one it saw before, or whether the key has changed in a way that should trigger caution.

This makes the file a trust anchor for SSH sessions. In practice, it supports the basic security promise that a saved host identity should not silently change without notice, which is why unknown or altered keys are treated as a potential interception event rather than a normal login detail.

Why host key verification matters

SSH connections are vulnerable when the client cannot reliably tell whether it is talking to the intended host. The known_hosts check reduces exposure to man-in-the-middle attacks by making host key changes visible at the point of connection, instead of accepting them as routine network noise.

The control is only as strong as the operator’s discipline around it. If users ignore warnings, accept new keys without validation, or carry stale entries across rebuilds and migrations, the file stops being a guardrail and becomes a source of false confidence.

For broader SSH trust and host key governance, SSH Key and SSH Certificate Management Guide covers the adjacent problems of key sprawl, rotation, orphaned keys, and host identity hygiene.

How organisations use it operationally

In managed environments, known_hosts entries are often created, distributed, or refreshed as part of server build, endpoint onboarding, bastion use, or automated deployment flows. That is useful, but it also means the file can become outdated quickly when hosts are rebuilt, reimaged, rekeyed, or replaced.

Teams should treat host key changes as an identity event, not just a connectivity event. A legitimate rebuild may explain the change, but so can a compromised host, cloned image, DNS abuse, or an unexpected network path that is intercepting traffic.

When host identity is managed through certificates rather than static fingerprints, the operational model changes. SSH Protocol and Certificate Authority Guide is relevant because certificate-based trust can reduce dependence on manually curated known_hosts entries for some environments.

What good hygiene looks like

A healthy known_hosts process is selective, reviewed, and consistent with the actual lifecycle of servers. It should support prompt detection of unexpected key drift, while avoiding brittle workflows where people reflexively bypass warnings just to get work done.

Good practice also depends on surrounding controls. Strong host key management is easier when SSH servers are hardened, host keys are not duplicated across images, and SSH access is monitored for anomalies and drift.

For example, Server Build and Golden Image Hardening Guide addresses the cloned-host-key problem, and OpenSSH Server Hardening Guide covers server-side settings that reduce weak SSH trust patterns.

Risk and Threat Considerations

The main risk is silent trust failure: if an attacker can present a different host key and the client accepts it, the SSH session may be redirected, observed, or altered without obvious user awareness. Stale or poorly maintained entries can also cause operators to override warnings that should have been investigated.

Failure mechanism: A changed or forged host key, combined with user habituation or weak validation processes, can turn an SSH warning into a bypassed control and allow man-in-the-middle interception or access to the wrong host.

Impact: The consequence can include session compromise, credential exposure, command tampering, and loss of trust in automation that relies on SSH for remote administration or file transfer.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST SP 800-53 Rev 5, CIS Controls v8 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementKnown_hosts helps validate SSH host identity and supports trust in SSH authentication flows.
IA-2 — Identification and Authentication (Organizational Users)SSH sessions depend on authenticated trust between client and server during remote administration.
IA-9 — Identification and Authentication (Non-Organizational Users)SSH trust checks also apply when external systems or non-human actors authenticate to SSH services.
Recommendation — Manage SSH host keys and related authenticators across their lifecycle, including rotation and revocation. Verify that remote administrative access uses strong authentication and trusted host verification. Use authenticated host verification for external and machine-to-machine SSH connections.
CIS Controls v8CIS-5 — Account ManagementSSH known_hosts hygiene is tied to managing trusted access paths and removing obsolete trust relationships.
Recommendation — Remove obsolete SSH trust entries and align host access records with current asset ownership.
NIST Zero Trust (SP 800-207)SC-2 — Zero Trust ArchitectureSSH host verification embodies the verify-explicitly principle and reduces implicit trust in network location.
Recommendation — Apply explicit verification for SSH endpoints instead of assuming network location implies trust.

Practitioner Guidance

What to watch for: Treat unexpected host key changes as a security event until you can explain them through a legitimate rebuild, rotation, or migration. In large fleets, align known_hosts management with image lifecycle, bastion policy, and approved key rotation so that exceptions are deliberate rather than ad hoc.

Practitioner takeaway: The file is not just a convenience cache, it is part of SSH trust governance, and it only helps when host identity changes are reviewed instead of normalised.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 29, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org