A quick, step-by-step guide to resolving the dreaded SSH host key verification failure when connecting to your Raspberry Pi or remote server.
We have all been there. You flash a fresh OS onto your Raspberry Pi, try to SSH back into it using the same hostname, and boomโyour terminal screens at you with a massive wall of warning text:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
...
Host key verification failed.
Why is this happening?
Your computer keeps a local registry of unique security keys (fingerprints) for every server you connect to inside a file named known_hosts.
When you reinstall an OS or change your remote device, its security key changes. Your computer notices that the new key doesn't match the old saved key, panics, and blocks the connection to protect you from a potential Man-in-the-Middle (MITM) attack.
Since you know you caused this change, it is safe to bypass. Here are the two quickest ways to fix it on Windows.
Solution 1: The One-Line Terminal Fix (Recommended) ๐
The fastest approach is to let the system automatically remove the old, conflicting key. Open your Command Prompt or PowerShell and run:
ssh-keygen -R raspberrypi.local
(Replace raspberrypi.local with your target IP address if you are connecting via IP).
What this does: It searches your local known_hosts file, strips out the outdated entry, and saves a backup of your old file just in case.
Solution 2: Manual Line Surgery ๐ ๏ธ
If the automated command fails or you prefer to see exactly what you are deleting, you can edit the file directly using Notepad.
- Press
Win + Rto open the Run window. - Paste the following path and click OK:
notepad C:\Users\PAVILION\.ssh\known_hosts
- Look at your original error message. It will tell you exactly which line is broken (e.g.,
offending ECDSA key in ...known_hosts:6). - Go to Line 6 in Notepad, delete that entire line, delete any blank spaces, and save (
Ctrl + S).
Connecting Again
Once the old key is cleared out, try connecting to your Raspberry Pi again:
ssh pi@raspberrypi.local
Your terminal will now ask if you want to trust the new fingerprint. Type yes, press Enter, and you are officially back in business!
Found this helpful? Drop a unicorn ๐ฆ or bookmark it for the next time you rebuild your homelab!
Top comments (0)