# Access to windows host machine on ubuntu local

**URL:** <https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984>\
**Category:** Get Help\
**Tags:** windows, ubuntu, aws, network\
**Created:** [April 16, 2024, 5:58pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984 "2024-04-16T17:58:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.ansible.com/u/simon)\
**Post date:** [April 16, 2024, 5:58pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/1 "2024-04-16T17:58:47Z")

</div>

Hello everyone!

I am new in ansible and have some issue interacting with windows host.

I configured `hosts` file like this

```auto
[windows_host]
34.235.150....

[windows_host:vars]
ansible_user=Administrator
ansible_password=kw=VPi*L)I4uzTp;
ansible_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
ansible_winrm_transport=basic

```

but timeout error occurs

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/d/d1e3093b06794dca6f281f0ad9b7ff77c2bb6712.png)

here, the windows machine is t2.micro on AWS.

If someone who knows, please help me.

Thanks.  
Simon

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [April 16, 2024, 6:07pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/2 "2024-04-16T18:07:27Z")

</div>

First, you should scrub your post. Don’t share sensitive information like the public IP’s and passwords.

Second, have you configured the windows machine for winrm over https? That’s not enabled by default.

Lastly, have you configured AWS to allow traffic between your ubuntu machine and windows machine? At least on the winrm ports?

---

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.ansible.com/u/simon)\
**Post date:** [April 16, 2024, 6:46pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/3 "2024-04-16T18:46:47Z")

</div>

Thanks very much.  
I’ve already configured security rule on aws.  
 ![image](https://us1.discourse-cdn.com/ansible/optimized/2X/a/a1835bc2c0151ae8d48a6f7e15252b0018627c2f_2_690x40.png)

and do you have any approach for configuring the windows machine for winrm over https?

Thanks again.

---

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.ansible.com/u/simon)\
**Post date:** [April 16, 2024, 6:57pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/4 "2024-04-16T18:57:52Z")

</div>

![image](https://us1.discourse-cdn.com/ansible/original/2X/2/2f92540badb4ab607c71cd8a7d0039ef1aefe1c8.png)  
And I noticed that WinRM is working by default from this.

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [April 16, 2024, 7:07pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/5 "2024-04-16T19:07:40Z")

</div>

> [@simon](#):
>
> And I noticed that WinRM is working by default

Windows servers enable winrm over http by default, but have no certificate to encrypt it over https. Only port 5985 will be listening on a fresh install.

> [@simon](#):
>
> do you have any approach for configuring the windows machine for winrm over https?

That’s a fairly deep subject. Ideally, you would use Group Policy and a CA server to issue trusted certificates from AD and enable winrm over https automatically. If you don’t have AD infrastructure to provide that, then you might be able to get away with a handful of commands:

```powershell
New-SelfSignedCertificate -DnsName ([system.net.dns]::GetHostByName($env:COMPUTERNAME).hostname
Set-WSManQuickConfig -UseSSL -Force -SkipNetworkProfileCheck 
Enable-PSRemoting -Force -SkipNetworkProfileCheck 

```

[Windows Remote Management — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/os_guide/windows_winrm.html)  
[Setting up a Windows Host — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/os_guide/windows_setup.html)

---

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.ansible.com/u/simon)\
**Post date:** [April 16, 2024, 7:19pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/6 "2024-04-16T19:19:29Z")

</div>

I really appreciate about your care.  
I tried the command you mentioned but seems not working… 😪

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/e/ec2b43d702e6130ac0c3bc80efb2ec7af48fee13.png)

---

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.ansible.com/u/simon)\
**Post date:** [April 16, 2024, 7:20pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/7 "2024-04-16T19:20:16Z")

</div>

And Is there any approach to connect with http if possible?

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [April 16, 2024, 7:34pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/8 "2024-04-16T19:34:21Z")

</div>

Maybe:

```auto
$fqdn = [system.net.dns]::GetHostByName($env:COMPUTERNAME).hostname
New-SelfSignedCertificate -DnsName $fqdn -Subject "CN=$fqdn"

```

As for http, you _can_ use it if you feel secure enough about it. WinRM uses its own encryption that Microsoft feels comfortable enough to enable WinRM over http for servers out of the box, but it doesn’t protect the initial handshake. So for a very brief moment, your sessions will be insecure. Enabling winrm over https will protect that intial handshake.

The main thing you would need to do is include the 5985 port in your AWS security rule, and then dumb down the ansible config to use http instead of https.

```auto
ansible_user=Administrator
ansible_password=kw=VPi*L)I4uzTp;
ansible_port=5985
ansible_connection=winrm
#ansible_winrm_server_cert_validation=ignore
ansible_winrm_transport=ntlm # please don't use basic if you can help it

```

---

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.ansible.com/u/simon)\
**Post date:** [April 16, 2024, 7:47pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/9 "2024-04-16T19:47:25Z")

</div>

Hi @Denny-tech, I am really thankful about your kind mentoring.

Unfortunately, both of https and http seems not working on my end.

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/c/c4b26c6efaf2b7bf0ebafe945028e728342ee3d7.png)  
my current OS is ubuntu and target is latest windows version on AWS AMI.

To solve this issue, Is there any method if the port 5986 or 5985 is opened on the target?

Our company is trying to use Ansible and it is R&D for me. 🙂  
Ansible worked well with ubuntu, but in terms of windows, it is really hard for me.

If you don’t mind, can we have a discussion on Telegram or Skype?  
If you don’t want, it 's okay enough for me.

Really Thank you. @Denney-tech. You are really good man.

Simon

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [April 16, 2024, 8:11pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/10 "2024-04-16T20:11:21Z")

</div>

My guess at this point is that you have a routing issue between your ubuntu host and windows host. Unfortunately, I don’t know enough about AWS to point you in the right direction.

You can test from your ubuntu vm though:

`nmap -p 5985-5986 -Pn 34.235.160.152`

Edit: This is a public IP address, and I would think you would want to connect to an internal IP address. Probably through a VPN, possibly through a bastion (which would mean either configuring powershell over ssh instead of WinRM or configuring a socks5 proxy).

---

<div class="post-metadata">

**Author:** ![alainseys](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alainseys/32/2757_2.png) [@alainseys](https://forum.ansible.com/u/alainseys)\
**Post date:** [June 11, 2024, 5:04pm UTC](https://forum.ansible.com/t/access-to-windows-host-machine-on-ubuntu-local/4984/11 "2024-06-11T17:04:37Z")

</div>

Do you have allowed the ports in awx (security groups) find the instance that member of one of those groups and allow winrm https port.

You should also limit the ips of the machines that you allow to talk to winrm like eg only your ubuntu machine to winrm.
