# Connecting to Linux and Windows hosts

**URL:** <https://forum.ansible.com/t/connecting-to-linux-and-windows-hosts/32643>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 9, 2020, 12:03pm UTC](https://forum.ansible.com/t/connecting-to-linux-and-windows-hosts/32643 "2020-04-09T12:03:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PH1](https://avatars.discourse-cdn.com/v4/letter/p/90ced4/32.png) [@PH1](https://forum.ansible.com/u/PH1)\
**Post date:** [April 9, 2020, 12:03pm UTC](https://forum.ansible.com/t/connecting-to-linux-and-windows-hosts/32643/1 "2020-04-09T12:03:27Z")

</div>

Please, help me to understand, how fill hosts file.  
Now i have linux hosts and it’s work’s fine.  
Exaple, how host file look’s like:

[all:vars]  
ansible\_connection=ssh  
ansible\_ssh\_user=user  
ansible\_ssh\_pass=user\_pass  
[host\_linux]  
192.168.[1:254].[1:3]

When trying to add windows hosts (ip adresses may be same as linux, because hosts about 1000 and i don’t know exatly where linux\windows installed) with windows vars - all hosts including linux and windows hosts began connecting using winrm.  
Host file looks like:

[host\_linux]  
ansible\_connection=ssh  
ansible\_ssh\_user=user  
ansible\_ssh\_pass=user\_pass  
[host\_linux]  
192.168.[1:254].[1:3]

[host\_windows:vars]  
ansible\_user=user  
ansible\_password=user\_pass  
ansible\_connection=winrm  
ansible\_winrm\_server\_cert\_validation=ignore  
ansible\_winrm\_transport=basic

[host\_windows]  
192.168.[1:254].[1:3]

How do I fill in the host file so that Linux hosts run using ssh, Windows hosts using winrm.

---

<div class="post-metadata">

**Author:** ![Ankit2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Ankit2](https://forum.ansible.com/u/Ankit2)\
**Post date:** [April 14, 2020, 12:38pm UTC](https://forum.ansible.com/t/connecting-to-linux-and-windows-hosts/32643/2 "2020-04-14T12:38:22Z")

</div>

Not sure if i get your question. You can specify the group specific variables including connection method like below. You need to identify their OS so that you could specify which host will use which connection method.

[all:vars]  
ansible\_connection=ssh  
ansible\_ssh\_user=user  
ansible\_ssh\_pass=user\_pass

[host\_linux]  
192.168.[1:254].[1:3]

[host\_linux:vars]  
ansible\_connection=ssh

[host\_windows]  
10.10.10.10

[host\_windows:vars]  
ansible\_connection=winrm
