Skip to content
Server and cPanel3 min read

Fixing "Host key verification failed"

Host key verification failed.

Short answer

The server's identity key (host key) doesn't match the one saved in known_hosts on your computer, or the server is unknown and the connection can't ask you about it. If you know the server changed, for example after a migration or reinstall, remove the old entry with ssh-keygen -R and reconnect, checking the new fingerprint.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. Causes
  2. How to fix it
  3. Prevention
  4. On ArabyHost

The first time you connect to a server, SSH saves its key in ~/.ssh/known_hosts and compares it on every later connection. That check stops you from talking to a machine impersonating your server. You get this error in two situations: the key changed, or the host is unknown and the connection can’t prompt you.

A changed key produces a loud warning:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Offending ED25519 key in /home/me/.ssh/known_hosts:7
Host key verification failed.

In scripts and CI you usually see No ED25519 host key is known for example.com and you have requested strict checking. instead, and Git adds fatal: Could not read from remote repository.

Causes

  • You moved your site to a new server or host, and the same domain now points to a machine with a different key.
  • The server was reinstalled or its keys regenerated.
  • An IP address was reassigned to a different server.
  • The provider rotated its key, as GitHub did with its RSA host key in 2023.
  • A non-interactive connection (GitHub Actions, cron, a deploy script) with no prepared known_hosts.
  • Rarely: a man-in-the-middle attack on an untrusted network.

How to fix it

1. Make sure the change is expected

Did you migrate, change nameservers or reinstall the server? Right after a DNS change you may reach either the old or the new server depending on DNS propagation. If nothing changed, stop, try another network and contact the server’s owner before going further.

2. Remove the old key

ssh-keygen -R example.com
ssh-keygen -R 203.0.113.10

For a non-standard port, use ssh-keygen -R "[example.com]:2222". The same command works in PowerShell on Windows, where the file lives at C:\Users\<name>\.ssh\known_hosts. Alternatively, delete the line number the warning names (known_hosts:7).

3. Reconnect and check the fingerprint

The authenticity of host 'example.com (203.0.113.10)' can't be established.
ED25519 key fingerprint is SHA256:...
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Compare the fingerprint with the one your provider publishes (GitHub lists its fingerprints in its official docs), then type yes.

4. In CI and scripts

Add the key once, after verifying it, and print its fingerprint to compare:

ssh-keyscan -t ed25519 example.com >> ~/.ssh/known_hosts
ssh-keygen -lf ~/.ssh/known_hosts

In GitHub Actions, store the verified known_hosts line as a secret and write it to the file before the deploy step, rather than running ssh-keyscan blindly on every run. If you only need new hosts accepted automatically, use -o StrictHostKeyChecking=accept-new.

Prevention

  • After any migration, update known_hosts on every machine and every CI/CD system that connects.
  • Always connect with the same name (domain or server hostname) so you don’t collect duplicate entries.
  • Keep your server’s key fingerprint somewhere safe to compare against when a warning appears.

On ArabyHost

SSH is available on the AI/Developer plans, on port 22. If you moved your site to us (with free migration help), seeing this warning on your first connection is normal because the server changed: remove the old line and accept the new key after checking it. The same applies to automated deploys, as in the deploy from GitHub guide. If the warning appears and nothing changed on your side, don’t accept the key; contact support first. And if you get past this error only to have your key refused, see Permission denied (publickey).

FAQ

Is it safe to delete the entry from known_hosts?

Yes, when you know why the key changed, such as moving your site to a new server. If nothing changed on your side, don't accept the new key until you've confirmed with the server's owner; the warning can mean the connection is being intercepted.

Why do I get this in GitHub Actions or a cron job?

Those connections are non-interactive, so ssh can't ask you to trust a new server. Add the server's key to known_hosts in advance, after checking its fingerprint.

Should I just use StrictHostKeyChecking=no?

Not as a fix: it switches the protection off entirely. accept-new is the better option, because it trusts a new host once and still refuses a key that changes later.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.