SSH "authenticity of host can't be established"
The first time OpenSSH reaches a host it has no stored key for, it shows the
key's fingerprint and asks whether to continue. This is a question, not an
error. It exists so that you can check you are talking to the machine you
meant, and it is worth thirty seconds before you type yes.
This page describes standard OpenSSH behaviour. The commands are the usual ones from the OpenSSH tools, and wording can differ a little between versions.
What the prompt says
The authenticity of host 'server.example.com (192.0.2.10)' can't be established.
ED25519 key fingerprint is SHA256:...
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
ssh has already reached something at that address, and it is showing you the key that thing offered. It has nothing recorded to compare against, so it cannot tell you whether the key is the right one. Nothing has been sent to the host yet: no password and no key signature.
This is not the
REMOTE HOST IDENTIFICATION HAS CHANGED
warning, which means a key is stored and the host now offers a different one.
It is also not a timeout, a refusal or Permission denied: the
connection worked, and login has not started.
Why you are being asked now
ssh asks when no entry in its known hosts files matches what you typed:
- You have never connected to this host from this account on this machine.
- The name is new. A different alias, or the address in place of the name, is a different entry, even for the same server.
-
The port is different. For a port other than 22,
known_hostsstores the bracketed form, such as[server.example.com]:2222, so the same machine on another port is a new host to ssh. -
The file is not the one you used before. A new laptop, a
new user account, a container, a fresh checkout of a build machine or a
cleaned-out home directory all start with an empty
known_hosts.
In each case the prompt is expected. If you were sure you had connected to this exact name and port before and the prompt appears anyway, look at which file ssh is reading before you assume anything about the host.
Check the fingerprint against a second source
The fingerprint on your screen arrived through the connection you are trying to verify. Comparing it with itself proves nothing. You need a copy that came another way. Good sources:
-
The machine's own console, or a shell you already trust on it. On a stock
OpenSSH server the host public keys sit next to the server config, and
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pubprints the fingerprint of one. Compare the line for the same key type that the prompt names. - The output of the installer, image build or provisioning step that created the machine, if it printed one and you kept it.
- The page or document of a public service that publishes its host key fingerprints, fetched over a connection you already trust.
- A colleague who read it at the console and who tells you over a channel other than the one under suspicion.
Compare the full SHA256: text, not the first few characters. If
you would rather not compare by eye, paste both into the
SSH key fingerprint checker. It runs
in your browser, sends nothing, and says whether the two match. Once the host
is saved, the line checker can read
the line ssh wrote and say what kind it is; it does not say whether the key is
the right one.
Do not use ssh-keyscan as the second source. It fetches the key
over the same network path as your connection, so if something is in the way,
both outputs come from it and they will agree.
Then decide
-
They match: answer
yes. ssh adds the key toknown_hostsand prints a line saying so. From then on, a different key for that name is the changed-key warning. If ssh instead printsFailed to add the host to the list of known hosts, that is a failed write and not the success line; it has its own page, SSH "Failed to add the host to the list of known hosts". -
They differ: answer
no. Check the name, address and port, and look at what could sit on the path, such as a captive portal, a proxy or a tunnel port that points at the wrong machine. Ask whoever runs it. -
You have no second source: answer
noif the host matters, and get one first. Typingyeson a guess is the same as not having the check.
Newer OpenSSH versions also accept the fingerprint itself, typed or pasted, as
the answer, which is a convenient way to confirm you are accepting the key you
checked. Older ones accept only yes and no.
Answering no, or running without a terminal where ssh cannot ask,
ends with Host key verification failed. In that case it just
means the key was not accepted, not that a stored key changed. To see what a
longer log shows, paste it into the
ssh -v output reader.
What not to do
Do not set StrictHostKeyChecking no to make the prompt go away,
and do not delete known_hosts. The first turns the check off for
every host it applies to, and the second throws away the recorded keys that
protect the hosts you have already verified. If the message you see is the
changed-key one, read
that guide and remove only the one
stale entry.
If the machine is a RescueShell device
RescueShell does not use this prompt for the device. The first time a browser connects to a device, the page asks you to check the device's fingerprint once. See the first-connection step in the troubleshooting page. A check made through the device does not replace checking a public SSH host that you still connect to directly. Those hosts keep their own prompt, and the steps above still apply to them.
Try it on one device
The first device is free to try with no card, for 30 days from when it connects, not from when you sign up. Start a trial.