# failing while connecting to Windows using AD credentials

**URL:** <https://forum.ansible.com/t/failing-while-connecting-to-windows-using-ad-credentials/24291>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 22, 2017, 10:14pm UTC](https://forum.ansible.com/t/failing-while-connecting-to-windows-using-ad-credentials/24291 "2017-04-22T22:14:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nergalgreed\_Es](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nergalgreed\_Es](https://forum.ansible.com/u/Nergalgreed_Es)\
**Post date:** [April 22, 2017, 10:14pm UTC](https://forum.ansible.com/t/failing-while-connecting-to-windows-using-ad-credentials/24291/1 "2017-04-22T22:14:50Z")

</div>

Hello all.

I am a ansible Rookie. I am trying to setup ansible to manage Windows machines. but i got some issues. here I will share some information about my system and my configuration.

I hope you can help me.

Thank you.

linux machine

Python 2.7.5  
REDHAT\_SUPPORT\_PRODUCT\_VERSION=“7.1”  
Red Hat Enterprise Linux Server release 7.1 (Maipo)  
kerberos 1.14.1  
ansible 2.2.1.0

kerberos configuration

/etc/krb5.conf.d/

[logging]  
default = FILE:/var/log/krb5libs.log  
kdc = FILE:/var/log/krb5kdc.log  
admin\_server = FILE:/var/log/kadmind.log

[libdefaults]  
dns\_lookup\_realm = true  
ticket\_lifetime = 24h  
renew\_lifetime = 7d  
forwardable = true  
rdns = false

# default\_realm = [EXAMPLE.COM](http://EXAMPLE.COM)

default\_ccache\_name = KEYRING:persistent:%{uid}

[realms]  
[STT.COM](http://STT.COM) = {  
kdc = [myserver.stt.com](http://myserver.stt.com)

}

[domain\_realm]  
.stt.com = [STT.COM](http://STT.COM)

when I run kinit the folloing error appeard

# kinit -C [myuser@STT.COM](mailto:myuser@STT.COM)

kinit: Cannot contact any KDC for realm ‘[STT.COM](http://STT.COM)’ while getting initial credential

ansible files

group\_vars/winndoes.yml  
ansible\_user: [myuser@STT.COM](mailto:myuser@STT.COM)  
ansible\_password: mypas  
ansible\_port: 5985  
ansible\_winrm\_transport: kerberos  
ansible\_winrm\_server\_cert\_validation: ignore

on my windows machine I executed the following command

@powershell -NoProfile -ExecutionPolicy Bypass -Command “iex ((new-object net.webclient).DownloadString(‘[https://github.com/ansible/ansible/raw/devel/examples/scripts/ConfigureRemotingForAnsible.ps1](https://github.com/ansible/ansible/raw/devel/examples/scripts/ConfigureRemotingForAnsible.ps1)’))”

when I run the following commnad ansible winnodes -i winhosts -m win\_ping

I got this  
ansible winnodes -i winhosts -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:** [April 24, 2017, 1:19am UTC](https://forum.ansible.com/t/failing-while-connecting-to-windows-using-ad-credentials/24291/2 "2017-04-24T01:19:10Z")

</div>

I can’t see the output of your execution with Ansible but your main issue is around the error message you get when running kinit with your domain account. It is unable to get the Kerberos ticket for your user as it can’t connect to your domain/realm. You will need to solve this issue first if you want to use Kerberos auth with Ansible but that is outside the scope of Ansible.

Once you resolve that it would be highly recommended to change the ansible\_port to 5986 so it is run over HTTPS and your messages are encrypted. If you don’t change this Ansible will probably fail as Windows by default doesn’t allow un-encrypted messages to be sent to it.
