AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Ansible Disable SSH Host Key Checking: Configuration Guide — Video Tutorial
How to disable SSH host key checking in Ansible. Configure ansible.cfg, environment variables, and per-host settings for lab and production environments.
What You'll Learn
- How to Ignore Ansible SSH Host Key Checking?
- SSH Host Key
- Links
- Playbook
- execution
- idempotency
- before execution
- after execution
- Conclusion
- Disable Host Key Checking
Full Tutorial Content
How to Ignore Ansible SSH Host Key Checking?
I'm going to show you a live Playbook with some simple Ansible code.
I'm Luca Berton and welcome to today's episode of Ansible Pilot.
SSH Host Key
> % ssh devops@demo.example.com
> The authenticity of host 'demo.example.com (192.168.0.190)' can't be established.
> RSA key fingerprint is SHA256:42JErOjO9fKNNBapEEyhpfTNn+rt8SPNob00uRlmqRs.
> This key is not known by any other names
> Are you sure you want to continue connecting (yes/no/[fingerprint])?
A host key is a cryptographic key used for authenticating computers in the SSH protocol.
Host keys are normally generated automatically when OpenSSH is first installed or when the computer is first booted.
In a production environment is considered a security mechanism to verify our machine has not been altered.
However, in a developer laboratory often, we need to destroy our machines often and recreate them. This behavior stops the Ansible execution and requires some manual developer work. We can apply this behavior also in a CI/CD pipeline or cloud computing provider.
Links
- [HOST_KEY_CHECKING](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#host-key-checking)
Playbook
How to Ignore Ansible SSH Host Key Checking in our Ansible laboratory.
I'm going to show how to create a ansible.cfg file to ignore the SSH Host Key Checking at the beginning of the Ansible Playbooks execution.
- ansible.cfg
```ini
[defaults]
host_key_checking = False
```
- ping.yml
```yaml
---
- name: ping module Playbook
hosts: all
tasks:
- name: test connection
ansible.builtin.ping:
```
- inventory
```ini
demo.example.com
```
execution
```bash
$ ansible-playbook -i inventory ping.yml
PLAY [ping module Playbook] *****************************************************************
TASK [Gathering Facts] ******************************************************************
ok: [demo.example.com]
TASK [test connection] ******************************************************************
ok: [demo.example.com]
PLAY RECAP ******************************************************************************
demo.example.com : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
```
idempotency
```bash
$ ansible-playbook -i inventory ping.yml
PLAY [ping module Playbook] *****************************************************************
TASK [Gathering Facts] ******************************************************************
ok: [demo.example.com]
TASK [test connection] ******************************************************************
ok: [demo.example.com]
PLAY RECAP ******************************************************************************
demo.example.com : ok=2 changed=0 unreachable=0 failed=0
```
before execution
```bash
$ ansible-playbook -i inventory ping.yml
PLAY [ping module Playbook] *****************************************************************
TASK [Gatherin
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 7 min
- Category: installation
Read the full written article: Ansible Disable SSH Host Key Checking: Configuration Guide
Related Video Tutorials
- ansible.cfg Configuration File: Complete Settings Guide (2026) — Complete guide to ansible.cfg configuration file. Every section explained — defaults, privilege_escalation, ssh_connection, inventory, galaxy. Plus ansible-config list, dump, view, and init commands with examples.
- Configure Ansible Dynamic Inventory for VMware in Simple Steps — Discover how to configure Ansible Dynamic Inventory for VMware to automate and manage virtual machines efficiently. Step-by-step guide with Playbook included.
- Ansible playbook_dir: Get Current Playbook Path (Magic Variable Guide) — How to use Ansible's playbook_dir magic variable to get the current playbook directory path. Includes role_path, inventory_dir, and all magic variables with examples.
- Three options to Safely Limit Ansible Playbooks Execution to a Single Machine — Three options to safely limit Ansible Playbook execution to a single machine using runtime parameters, playbook code, and variables.
- Mastering Ansible Command: Ad-Hoc Tasks and System Management — Explore the basics of the Ansible command, including how to run ad-hoc tasks, execute modules, and retrieve system facts. Perfect for beginners and intermediate users.
- Ansible Magic Variables: Complete Reference with Examples — Complete reference for Ansible magic variables. Use inventory_hostname, hostvars, groups, play_hosts, ansible_facts, and special variables in playbooks.