How to bypass host key checking In Ansible

In the early days of network computing, effectively managing servers was complicated. Server administrators find managing servers, software installations, configurations, and other factors challenging as hosted applications get more complicated.

Ansible is a tool for managing server setup and provisioning that makes the job of server administrators easier. Ansible can target the infrastructure's hosts at the same time. It does this by using an inventory list or collection of inventories. However, turning off host key checking is occasionally necessary, which might be challenging.

Bypassing host key checking

In the host key verification process, SSH automatically updates and verifies a database containing information on every host it has ever used. Additionally, StrictHostKeyChecking aids in limiting login attempts to computers whose host key has changed. This argument’s value no instructs SSH not to update the known user's host files with new host keys automatically. Additionally, we have the option of global or host/inventory level disablement.

The command listed below is used to deactivate it at the inventory level.

ansible_ssh_common_args='-o StrictHostKeyChecking=no'
Inventory level disabling

To deactivate it at the host level, we can use the following command.

ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
Host level disabling

The inventory/hosts method seems safer but only supports SSH connections, not Paramiko connections. Additionally, we add the following to /etc/ansible/ansible.cfg to implement it globally.

host_key_checking = False
Disabling globally

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved