Interview Prep/Ansible/Connection and SSH Failures

`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.

All Ansible questions Roadmap: Ansible

More on Connection and SSH Failures