# Unreachable : Failed to connect to the host via ssh

**URL:** <https://forum.ansible.com/t/unreachable-failed-to-connect-to-the-host-via-ssh/33248>\
**Category:** Ansible Project\
**Tags:** windows, rhel, aws\
**Created:** [June 24, 2020, 1:18pm UTC](https://forum.ansible.com/t/unreachable-failed-to-connect-to-the-host-via-ssh/33248 "2020-06-24T13:18:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahesh\_b](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@Mahesh\_b](https://forum.ansible.com/u/Mahesh_b)\
**Post date:** [June 24, 2020, 1:18pm UTC](https://forum.ansible.com/t/unreachable-failed-to-connect-to-the-host-via-ssh/33248/1 "2020-06-24T13:18:24Z")

</div>

Dear All,

I have created my RHEL 8, AWS EC2 instances and Windows 2019 AWS EC2 instance

And, have installed Ansible and followed the prerequisites on control node.

Equally I have created user and ran the script [https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/\*\*ConfigureRemotingForAnsible.ps1\*\*](https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ **ConfigureRemotingForAnsible.ps1** ) from windows machine.

Also installed Pywinrm on control node and updated inventory file carefully as below:

[winhost:vars]  
ansible\_user=mahesh  
ansible\_password=password  
ansible\_connection=winrm  
ansible\_winrm\_server\_cert\_validation=ignore

Now when I start ping my windows machine it is returning me an error: -

UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh: ssh: connect to host XX.XX.XX.XX port 22: Connection timed out”,  
“unreachable”: true

}

Though I mentioned the `host vars` section is: `ansible_winrm_server_cert_validation=ignore, it is still checking ssh and kept on faily.`

`I request can someone suggest in this regards`

`Thank you very much in advance for your suggestions!`

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [June 24, 2020, 1:48pm UTC](https://forum.ansible.com/t/unreachable-failed-to-connect-to-the-host-via-ssh/33248/2 "2020-06-24T13:48:20Z")

</div>

- Is this your entire inventory file? If not please post that
- What is the actual command you used to “ping” the windows machine?

---

<div class="post-metadata">

**Author:** ![Mahesh\_b](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@Mahesh\_b](https://forum.ansible.com/u/Mahesh_b)\
**Post date:** [June 24, 2020, 1:57pm UTC](https://forum.ansible.com/t/unreachable-failed-to-connect-to-the-host-via-ssh/33248/3 "2020-06-24T13:57:21Z")

</div>

Thanks for your response!

## Entire Inventory file -

[windows]  
XX.XX.XX.XX

[winhost:vars]  
ansible\_user=mahesh  
ansible\_password=India@1234  
ansible\_connection=winrm  
ansible\_winrm\_server\_cert\_validation=ignore

## Command used to ping windows servers -

ansible windows -m win\_ping

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [June 25, 2020, 12:04am UTC](https://forum.ansible.com/t/unreachable-failed-to-connect-to-the-host-via-ssh/33248/4 "2020-06-25T00:04:16Z")

</div>

You have defined the vars for the group ‘winhost’ but have defined the host in the group ‘windows’. That’s why the connection and other vars are not being applied to the host when running.

---

<div class="post-metadata">

**Author:** ![Mahesh\_b](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@Mahesh\_b](https://forum.ansible.com/u/Mahesh_b)\
**Post date:** [June 25, 2020, 1:26am UTC](https://forum.ansible.com/t/unreachable-failed-to-connect-to-the-host-via-ssh/33248/5 "2020-06-25T01:26:34Z")

</div>

Thanks a ton, it’s a great clue.

I confirm now my windows server is started responding from Ansible.

Ping = Success.

Thanks again!
