Tuesday, April 19, 2022

[SOLVED] running into error of "UNREACHABLE" "permission denied" while running ansible playbook

Issue

I entered this code ansible all -m ping to verify that the host that I added is running under ansible server but I get that error message:

192.168.186.137 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,keyboard-interactive).\r\n", "unreachable": true }

so how to make that ip address reachable?


Solution

Ensure you have an inventory with the correct settings to connect to your host.

E.g.

  [local_test]
  hostname_of_host ansible_ssh_user=<your_ssh_user> ansible_host=<ip> ansible_ssh_port=22 ansible_ssh_private_key_file=<path_to_key>

Call Ansible with ansible local_test -i inventory.

Also, make sure you can connect to your host. Place those variables in the inventory file.



Answered By - Kevin C
Answer Checked By - David Marino (WPSolving Volunteer)