# Can't get Ansible to work

**URL:** <https://forum.ansible.com/t/cant-get-ansible-to-work/40580>\
**Category:** Get Help\
**Created:** [February 24, 2025, 3:49am UTC](https://forum.ansible.com/t/cant-get-ansible-to-work/40580 "2025-02-24T03:49:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcyrus](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jcyrus](https://forum.ansible.com/u/jcyrus)\
**Post date:** [February 24, 2025, 3:49am UTC](https://forum.ansible.com/t/cant-get-ansible-to-work/40580/1 "2025-02-24T03:49:00Z")

</div>

Hello,

New user trying to get Ansible to work for the first time. I setup a hosts file and created a simple ansible.cfg file and a test user. I was trying to use the ping module to test connectivity, but it fails with an authentication error every time. I am able to connect via ssh to the remote hosts with the test user account. I’m not sure what I’m doing wrong at this point. Any ideas would be great.

Thank you

---

<div class="post-metadata">

**Author:** ![iwt-cmd](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwt-cmd/32/9120_2.png) [@iwt-cmd](https://forum.ansible.com/u/iwt-cmd)\
**Post date:** [February 24, 2025, 1:52pm UTC](https://forum.ansible.com/t/cant-get-ansible-to-work/40580/2 "2025-02-24T13:52:05Z")

</div>

Hi jcyrus,

This will depend on some of your configs and what you’re trying to automate against. I’m assuming you’re attempting to run from the command line and connecting to a Linux host. A couple things to check:

- Are you using a password or SSH keys? If the latter, has the key been added to the remote host under the username you’ve setup in Ansible?
- Have you confirmed that the hostname in the inventory is valid? This could be an FQDN or IP address.

Looking at your ansible.cfg, inventory and playbook files could help as well as the output of the playbook run (including the command used to run it). Sanitize as needed if there are any passwords, plain text keys or outside IP addresses listed.

I tried to find a getting start guide on the Ansible docs that has details on how to prep your targets hosts but didn’t find anything easy in one place. I’ll take another look later on and send back some links. I would check out Jeff Geerling’s Ansible 101 YouTube series when you have time ( [Ansible 101 - YouTube](https://www.youtube.com/playlist?list=PL2_OBreMn7FqZkvMYt6ATmgC0KAGGJNAN)). Great beginner-focused info even though it’s a few years old.

Best regards,

Joe

---

<div class="post-metadata">

**Author:** ![kristianheljas](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kristianheljas/32/7702_2.png) [@kristianheljas](https://forum.ansible.com/u/kristianheljas)\
**Post date:** [February 24, 2025, 1:52pm UTC](https://forum.ansible.com/t/cant-get-ansible-to-work/40580/3 "2025-02-24T13:52:44Z")

</div>

How are you authenticating to the server?

If you are using password authentication you may need to provide it via [–ask-pass](https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html#cmdoption-ansible-playbook-k) option for ansible.

If thats not the case, please provide more details like the exact error and possibly error output when running ansible with `-vvv` option for more verbosity.

---

<div class="post-metadata">

**Author:** ![jcyrus](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jcyrus](https://forum.ansible.com/u/jcyrus)\
**Post date:** [February 24, 2025, 3:16pm UTC](https://forum.ansible.com/t/cant-get-ansible-to-work/40580/4 "2025-02-24T15:16:30Z")

</div>

To answer both of you :

I am using password authentication and I am able to connect to both hosts via ssh username@IPADRESS without issue. I can post my ansible.cfg file and the error message later when I’m not at work. There is no sensitive info as I’m just labbing trying to figure out how to use Ansible.

I’m confident this is just me not know where to modify config files or something simple.

Thank you for your responses.

---

<div class="post-metadata">

**Author:** ![jcyrus](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jcyrus](https://forum.ansible.com/u/jcyrus)\
**Post date:** [February 25, 2025, 3:12am UTC](https://forum.ansible.com/t/cant-get-ansible-to-work/40580/5 "2025-02-25T03:12:34Z")

</div>

Here is the contents of my ansible.cfg file:

[defaults]

inventory = /etc/ansible/hosts

remote\_user = ansible

host\_key\_checking = False

Host file contents:

[debian]

10.15.10.xx  
10.15.10.yy

I tried the command with --ask-pass and that seemed to work. So can I assume that if I setup key pairs it will work moving forward with just the comman “ansible debian -m ping” ?

---

<div class="post-metadata">

**Author:** ![kristianheljas](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kristianheljas/32/7702_2.png) [@kristianheljas](https://forum.ansible.com/u/kristianheljas)\
**Post date:** [February 25, 2025, 3:39am UTC](https://forum.ansible.com/t/cant-get-ansible-to-work/40580/6 "2025-02-25T03:39:08Z")

</div>

Correct, ssh keys are the way to go.

The preferred way is to use ssh agent. It also allows you to use passphrase protected key file.

See [Connection methods and details — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/inventory_guide/connection_details.html#setting-up-ssh-keys)

Alternatively you can specify the unprotected key location with `ansible_ssh_private_key_file` variable. See [this link](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html#parameter-private_key_file) for alternatives to the variable.
