Skip to main content

SSH to QEMU VM - Fix Host Key Verification Error

Table of Contents

This warning means the SSH host key for localhost:2222 has changed since the last time you connected — very likely because:

  • You recreated or reinstalled the VM, or
  • You’re using a different VM on the same forwarded port (2222).

This is a normal safety feature to prevent man-in-the-middle attacks, but since you’re testing locally and you control both host and guest, it’s safe to fix.


✅ To resolve the issue:
#

Edit the known_hosts file to remove the offending entry:

ssh-keygen -R [localhost]:2222

This will remove the old key from ~/.ssh/known_hosts.

Then retry:

ssh -p 2222 user@localhost

The new key will be added, and the warning will go away.


Youcef
Author
Youcef
My name is youcef and i’m linux user who fool in love with linux , like free and open software .