`Host key verification failed.` after rebuilding a server
BeginnerTroubleshootingConnection and SSH Failures
Answer
Likely causes → The host was recreated with a new host key but known_hosts has the old one.
Diagnose → ssh-keygen -F web01 and compare the fingerprint.
Fix →
ssh-keygen -R web01
ssh-keyscan -H web01 >> ~/.ssh/known_hosts
For short-lived hosts: ansible_ssh_common_args: '-o StrictHostKeyChecking=accept-new'.
Prevent → Prefer accept-new over disabling checks, and publish host keys via SSHFP or your CA. Avoid host_key_checking = False in production.
More on Connection and SSH Failures
`UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: Permission denied (publickey,password)."}`Beginner`UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: ssh: connect to host 10.0.1.15 port 22: Connection timed out"}`Beginner`UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: ssh: connect to host web01 port 22: Connection refused"}`BeginnerThe playbook hangs for ever at "Gathering Facts" on one hostIntermediate`Failed to connect to the host via ssh: Too many authentication failures`Intermediate`fatal: [web01]: UNREACHABLE! => {"msg": "Failed to connect to the host via ssh: Shared connection to web01 closed."}` mid-runIntermediate