Oct 31, 2021

Ansible ERROR! Using a SSH password instead of a key is not possible

Let us see very simple solution for below ansible error when running playbook.

FAILED! => {"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host."}

Issue:
Ansible verifying host key.

Solution:
create "ansible.cfg" file and below message:

vi ansible.cfg

[defaults]
host_key_checking = false

Note: Ansible version 2.6.2 and solution with host_key_checking = false doesn't work
This error can also be solved by simply export ANSIBLE_HOST_KEY_CHECKING variable.

export ANSIBLE_HOST_KEY_CHECKING=False

Demo:

when ansible.cfg not there or "host_key_checking = false" is commented in ansible.cfg file.


# cat test01.yml
---

- hosts: all
  vars:
   fail: false

  tasks:
   - fail: msg="Congrats, you asked for this playbook to fail ... and it has"
     when: fail
 
-- Check the syntax for the newly created yml
"
# ansible-playbook test01.yml --syntax-check

playbook: test01.yml

-- play your play book

# ansible-playbook test01.yml

PLAY [all] **************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
fatal: [192.168.100.1]: FAILED! => {"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host."}
fatal: [192.168.100.2]: FAILED! => {"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host."}

PLAY RECAP **************************************************************************************************************************************************
192.168.100.1             : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
192.168.100.2             : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

playbook: test01.yml
#


after adding "ansible.cfg" file and below message:

vi ansible.cfg

[defaults]
host_key_checking = false

# ansible-playbook test01.yml --syntax-check

playbook: test01.yml
# ansible-playbook test01.yml

PLAY [all] **************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
[WARNING]: Platform linux on host 192.168.100.2 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python
interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [192.168.100.2]
[WARNING]: Platform linux on host 192.168.100.3 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python
interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [192.168.100.3]

TASK [fail] *************************************************************************************************************************************************
skipping: [192.168.100.3]
skipping: [192.168.100.2]

PLAY RECAP **************************************************************************************************************************************************
192.168.100.2             : ok=1    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
192.168.100.3             : ok=1    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

#


Here, check the warnings and fix accordingly. There are no issues.

4 comments:

  1. A few months ago, I felt so depressed, I got frustrated with bad credits, but then I contacted HACK VANISH by phone: +1 (747) 293-8514 and email: HACK VANISH (@) GMAIL. COM. I found out about hack vanish services through positive reviews read on some credit blogs, in a blink of an eye this great hacker restored my credit score from 509 to 784 in all 3 major credit bureaus, they got removed evictions and foreclosures, my LexisNexis and Chex system was repaired respectively, a few days later I received an email confirming the approval of my mortgage loan, it was quite surprising because I never thought it was possible. Today, I can confidently say that 2021 was a banner year for my husband and I as we now own a new house and a new SUV courtesy of HACK VANISH, I would definitely recommend him to anyone in need of a genuine Hacker.

    ReplyDelete
  2. All thanks to Mr Anderson for helping with my profits and making my fifth withdrawal possible. I'm here to share an amazing life changing opportunity with you. its called Bitcoin / Forex trading options. it is a highly lucrative business which can earn you as much as $2,570 in a week from an initial investment of just $200. I am living proof of this great business opportunity. If anyone is interested in trading on bitcoin or any cryptocurrency and want a successful trade without losing notify Mr Anderson now.Whatsapp: (+447883246472 )
    Email: tdameritrade077@gmail.com

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete

Translate >>