# Ansible to windows client connection

**URL:** <https://forum.ansible.com/t/ansible-to-windows-client-connection/29464>\
**Category:** Ansible Developer\
**Tags:** windows\
**Created:** [January 18, 2019, 12:30pm UTC](https://forum.ansible.com/t/ansible-to-windows-client-connection/29464 "2019-01-18T12:30:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sindhu\_shree](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sindhu\_shree](https://forum.ansible.com/u/sindhu_shree)\
**Post date:** [January 18, 2019, 12:30pm UTC](https://forum.ansible.com/t/ansible-to-windows-client-connection/29464/1 "2019-01-18T12:30:39Z")

</div>

Hi.  
Am facing some authentication issues when i run ansible all -m win\_ping. Response - 10.67.104.45 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “basic: the specified credentials were rejected by the server”,  
“unreachable”: true  
}

The user which am trying to connect is administrator user. I followed some steps to add user and change the permissions using

winrm configSDDL default, but no luck.  
Am using basic authentication.

Am new to Linux , i would appreciate if i get any help on this.

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [January 18, 2019, 4:40pm UTC](https://forum.ansible.com/t/ansible-to-windows-client-connection/29464/2 "2019-01-18T16:40:42Z")

</div>

Can you add -vvvvv to your playblook command to see more output?

---

<div class="post-metadata">

**Author:** ![sindhu\_shree](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sindhu\_shree](https://forum.ansible.com/u/sindhu_shree)\
**Post date:** [January 22, 2019, 10:01am UTC](https://forum.ansible.com/t/ansible-to-windows-client-connection/29464/3 "2019-01-22T10:01:59Z")

</div>

This is what am getting

ansible 2.4.2.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/sha re/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /bin/ansible  
python version = 2.7.5 (default, Sep 12 2018, 05:31:16) [GCC 4.8.5 20150623 (R ed Hat 4.8.5-36)]  
Using /etc/ansible/ansible.cfg as config file  
setting up inventory plugins  
Parsed /etc/ansible/hosts inventory source with ini plugin  
Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python2.7/sit e-packages/ansible/plugins/callback/ **init**.pyc  
META: ran handlers  
Using module file /usr/lib/python2.7/site-packages/ansible/modules/windows/win\_p ing.ps1  
\<10.67.104.45\> ESTABLISH WINRM CONNECTION FOR USER:username on P ORT 5986 TO 10.67.104.45  
\<10.67.104.45\> WINRM CONNECT: transport=basic endpoint=[https://10.67.104.45:5986](https://10.67.104.45:5986) /wsman  
\<10.67.104.45\> WINRM CONNECTION ERROR: the specified credentials were rejected b y the server  
Traceback (most recent call last):  
File “/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py”, l ine 222, in _winrm\_connect  
self.shell\_id = protocol.open\_shell(codepage=65001) # UTF-8  
File “/usr/lib/python2.7/site-packages/winrm/protocol.py”, line 157, in open\_s hell  
res = self.send\_message(xmltodict.unparse(req))  
File “/usr/lib/python2.7/site-packages/winrm/protocol.py”, line 234, in send\_m essage  
resp = self.transport.send\_message(message)  
File “/usr/lib/python2.7/site-packages/winrm/transport.py”, line 256, in send_ message  
response = self.\_send\_message\_request(prepared\_request, message)  
File “/usr/lib/python2.7/site-packages/winrm/transport.py”, line 266, in \_send \_message\_request  
raise InvalidCredentialsError(“the specified credentials were rejected by th e server”)  
InvalidCredentialsError: the specified credentials were rejected by the server

10.67.104.45 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “basic: the specified credentials were rejected by the server”,  
“unreachable”: true  
}

Listener setup:

$selector\_set = @{  
Address = “\*”  
Transport = “HTTPS”  
}  
$value\_set = @{  
CertificateThumbprint = “EF39ECD8A40F83ACC2BE85D95303EED2EB7DCE5C”  
}

New-WSManInstance -ResourceURI “winrm/config/Listener” -SelectorSet $selector\_set -ValueSet $value\_set

Basic winrm setup :

$url = “[https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1](https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1)”  
$file = “$env:temp\ConfigureRemotingForAnsible.ps1”  
$username = "username "  
$password = “password”

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force  
$browser = New-Object System.Net.WebClient  
$browser.Proxy.Credentials =[System.Net.CredentialCache]::DefaultNetworkCredentials  
$browser.DownloadFile($url, $file)

# version can be 3.0, 4.0 or 5.1

#&$file -Version 3.0 -Username $username -Password $password -Verbose

#(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)

powershell.exe -ExecutionPolicy ByPass -File $file

I just checked the connection with other windows power shell as follows.

PS C:\Users\sindhu.p\> winrs -r:[https://ipaddress:5986/wsman](https://ipaddress:5986/wsman) -u:username -p:password ipconfig

Error :

Winrs error:The server certificate on the destination computer ([10.67.104.45:5986](http://www.google.com/url?q=http%3A%2F%2F10.67.104.45%3A5986&sa=D&sntz=1&usg=AFQjCNGbPspFWnu-c2p7l4Fbl4njC8yq4g)) has the following errors:  
The SSL certificate is signed by an unknown certificate authority.  
The SSL certificate contains a common name (CN) that does not match the hostname.
