Fix SSH 'WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED' and 'Host key verification failed'
Safely remove a stale host key from known_hosts after a server rebuild or IP reuse, and verify the new fingerprint before trusting it.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Host key verification failed.
# 1. Remove the old key for 203.0.113.10 ssh-keygen -R 203.0.113.10 # 2. Fetch and print the new fingerprint BEFORE trusting it ssh-keyscan -t ed25519 203.0.113.10 | ssh-keygen -lf - # 3. If it matches your provider's console / docs, connect ssh user@203.0.113.10
Root Cause & Mechanism Analysis
Why does this error occur?
The server presented a different host key than the one stored in `~/.ssh/known_hosts`. This is expected after reinstalling a VPS, rebuilding a container, or when a cloud provider reassigns an IP — but it is also exactly what a man-in-the-middle attack looks like.
Frequently Asked Questions
Is it safe to just delete ~/.ssh/known_hosts?
Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?
Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.
Related Developer Error Solutions
Browse All 69 GuidesSSH: Permission denied (publickey)
Resolve SSH authentication failures caused by wrong file permissions, missing keys, or SSH agent issues.
SSL: NET::ERR_CERT_AUTHORITY_INVALID
Resolve SSL/TLS certificate trust errors in development, curl, Node.js, and local HTTPS environments.
Git: error: failed to push some refs to origin
Resolve rejected pushes caused by remote commits you do not have locally, protected branches, or secret-scanning push protection.