An SSH host-key warning interrupts a familiar workflow for an important reason: the server identity no longer matches what the client expected. Sometimes a legitimate rebuild or key rotation explains the change. Sometimes the destination, DNS, routing, or server is not what you intended. Deleting the warning’s evidence before checking the cause makes those cases harder to distinguish.
The OpenBSD manuals for ssh-keyscan and SSH client configuration explain the distinction between gathering a host key and verifying it. This guide uses that distinction to build a practical identity-checking workflow for authorized servers and deployment automation.
Host authentication is not user authentication
A user key or password helps the server decide who you are. A host key helps your client decide which server it is connecting to. Successful user authentication is not an independent substitute for host identity verification. The two checks protect different directions of trust in the connection.
The known-hosts record gives the client an expected identity for a destination. If the presented key changes, the warning means that expectation needs review. It does not automatically prove malicious activity, but it should not be reduced to a cosmetic error either.
Think of the question as “why did this identity change?” rather than “how do I make SSH stop asking?” That wording leads to better evidence: a documented rebuild, an approved rotation, the exact hostname and port, and a verified new fingerprint. It also discourages broad exceptions that outlive the immediate incident.
Verify the destination first
Confirm the hostname, address, port, and environment you intended to reach. Similar names, staging and production aliases, or a reused address can explain surprising identity results. Check the approved inventory rather than assuming a familiar shell history entry still points to the same machine.
If a bastion or other intermediary is part of the workflow, understand which host’s identity is being checked at each step. A connection path can include more than one trust boundary. Do not fix a warning for the destination by weakening checks for every host in a shared configuration file.
For a managed service, contact the responsible administrator through an established channel. A message received over the same potentially suspect connection is not necessarily independent evidence. Use a trusted console, approved inventory system, or another verified administrative path as appropriate to the environment.
ssh-keyscan collects, but does not authenticate
The ssh-keyscan manual says the tool gathers public host keys and does not need login access to the scanned hosts. It explicitly warns that it cannot verify the authenticity of the keys it obtains. An attacker able to intercept traffic could substitute a different key.
That means a successful scan is a collection result, not a completed identity check. Appending its output directly to a trust file without verification can institutionalize the very identity you were trying to evaluate. Convenience in automation does not turn an unverified network observation into a trusted record.
Use collection as one step in a wider process. Compare the collected key or fingerprint with information obtained through an approved independent path, or apply the organization’s documented trust model. Scan only the hosts and networks you are authorized to administer; a public manual is not permission to inventory unrelated infrastructure.

First connections need a trust decision too
A host that has never been recorded does not trigger the same change comparison as a previously known host. The first acceptance therefore deserves its own verification process. A user clicking “yes” without checking anything has made a trust decision, even if the interface makes that decision feel routine.
The SSH configuration manual distinguishes strict checking, asking before adding new keys, and accepting new keys automatically. It says accept-new can add new host keys but refuses changed ones. That is not the same as independently verifying a first-seen key. Choose a policy that matches your environment’s documented identity-distribution process.
For unattended automation, provide approved host identity information before the job runs where possible. A deployment runner should not have to invent a trust policy during its first production connection. Keep ownership clear so key changes can be reviewed without emergency edits to security settings.
Handle a legitimate change narrowly
If the administrator confirms a rebuild or approved rotation through a trusted channel, compare the expected new identity and update only the relevant record through the supported process. Preserve enough information to explain the change. Do not erase the entire known-hosts file simply because one entry needs maintenance.
Check aliases and nonstandard ports that may have separate records in your environment. A narrow update should address the destination actually changing, not every similarly named machine. If multiple keys are supported, review the server’s intended key set and your client’s behavior rather than assuming one fingerprint describes every configuration.
After the update, reconnect using the normal checking policy and confirm the approved identity is accepted. If the warning persists, stop and resolve the mismatch. Repeatedly deleting records without understanding why different keys appear can conceal an unstable or incorrect connection path.
Planned rotation is better than emergency acceptance
The manual describes UpdateHostKeys as supporting graceful rotation by learning additional host keys after authentication under stated conditions. The new keys are not simply accepted from any unauthenticated server. The documented behavior depends on existing trust and the authentication path used.
Use that feature only within a reviewed rotation plan and supported client/server configuration. Defaults and applicability can change when known-hosts files or other options are customized. Check the manual for the exact client version instead of assuming a setting works identically across every operating system and automation image.
A rotation plan should include advance communication, the trusted distribution path, the rollout sequence, and verification that old keys are removed when appropriate. It should also describe what an operator does if an unexpected warning appears during the window. “Everyone disable checking temporarily” is not a careful rotation strategy.

Keep automation’s trust files maintained
CI runners and deployment systems often have their own known-hosts storage. Verify the file used by the actual job rather than updating only your laptop. A container image may contain an outdated record, or a fresh runner may start with no approved identities at all.
Store host-identity configuration through an authorized process and review changes like other security-relevant configuration. Public host keys are not private keys, but the integrity of the approved record matters. If someone can replace the expected identity silently, the client may trust the wrong endpoint.
Keep private user keys and deployment credentials separate from host-identity records. Never paste them into a troubleshooting ticket to explain a fingerprint mismatch. Most useful diagnostics can describe the destination, client version, expected public identity, and observed warning without exposing authentication secrets.
When the cause is not explained
If the change cannot be verified, do not continue sensitive work over the connection merely because the server accepts your credentials. Escalate through the responsible operations or security process. Preserve the warning and relevant connection details while avoiding unnecessary disclosure of internal infrastructure information.
An unexplained change needs investigation, not an automatic conclusion that an attack happened. The result may be an inventory mistake, an unauthorized rebuild, or a network issue. The important point is that trust remains unresolved until there is an adequate explanation and verified identity.
The takeaway
Gathering an SSH host key is not verifying it. Treat first acceptance and later changes as explicit identity decisions, use independent approved evidence, and update only the relevant records. A maintained trust process makes secure automation more reliable instead of turning every warning into a bypass.
Source checked October 8, 2026. Recheck the ssh-keyscan manual and SSH configuration reference for your client’s supported behavior.
