Ansible Windows Error “msg”: “plaintext: the specified credentials were rejected by the server”

In this post, I will show you how to fix the connection issues that prevent ansible from connecting to a Windows host.

Error

The full error message is shown below.

192.168.0.15 | UNREACHABLE! => {
“changed”: false,
“msg”: “plaintext: the specified credentials were rejected by the server”,
“unreachable”: true

Solution

the reason you receving this error is because WinRM is not configured properly and not using secure port to encypt the communication with the Windows machine.

The solution here is to configure WinRM using the Ansible WinRM configuration script and retry the connection. Below I have listed all the commands you need to run which include:

  • Creating a new directory called scripts
  • Downloading the Ansible WinRM configuration script
  • Run the script
cd c:\
 new-item scripts -Type directory 
cd c:\scrips 
wget -Uri https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile winrm.ps1 .\winrm.ps1

After runing the WinRM configuration the connection should work and as shown below it is working.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.