Ansible disable host key checking
Are you stuck with Ansible disable host key checking? We can help you with it.
For a wide variety of automation challenges, Ansible provides a significant productivity gain.
Why ansible disable host key checking?
Before getting into the topic, let’s first discuss the importance of Ansible.
At the beginning of network computing, managing servers efficiently was a significant challenge. As hosted applications get more complex, server administrators find it difficult to manage servers, software installations, configurations, and so on. And, Ansible is a server provisioning and configuration management tool that makes the Server administrator’s task more manageable. Ansible can work against multiple hosts in the infrastructure at the same time. To do so, it uses a list or group of lists known as inventory. But, sometimes, we need to disable the host key checking, and it often appears as a confusing task.
How we disable host key checking?
Recently, one of our team members approached me with an ansible error. He tried to set host_key_checking=false in the host’s file, but it did not work.
Our team checked and found errors with the command.
In the host key checking, ssh automatically maintains and checks a database that contains identification for all hosts it has ever been used with. And, StrictHostKeyChecking helps to control logins to machines whose host key has changed. Setting this argument “no” prompts ssh to automatically add new host keys to the user’s known host files.
We could disable it at the host/inventory level or global level.
To disable it at the inventory level, we use the below command.
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
Similarly, to disable it at the host level,
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
Inventory/hosts method appears to be more secure but it only works with connection type ssh and not paramiko.
Also, to do it at the global level, we add the following in /etc/ansible/ansible.cfg.
host_key_checking = False
Therefore, using these methods, we can disable the host key checking.
Conclusion
In short, we can do Ansible disable host key checking either at the inventory/hosts level or global level. In today’s writeup, we discussed how our Engineers disable it easily.