Ssh – Ansible: Failed to connect to the host via ssh

ansiblecygwinrhel7ssh

Anyone know why this isn't working?

I'm using Ansible on Cygwin using a compiled version of sshpass. I followed the instructions at http://www.jeffgeerling.com/blog/running-ansible-within-windows for setting it up. Here's my /etc/ansible/hosts file:

10.240.227.56 ansible_ssh_pass='password' ansible_user='domain\userid'
10.240.227.59 ansible_ssh_pass='password' ansible_user='domain\userid' ansible_become=true ansible_become_method=sudo ansible_become_user=privilegeduser

I was trying this out with two different hosts and two different configurations to see if I could narrow down the problem, but they are behaving identically. Here's what I get when I try to ping the hosts:

$ ansible all -vvv -m ping
No config file found; using defaults
<10.240.227.56> ESTABLISH SSH CONNECTION FOR USER: domain\userid
<10.240.227.59> ESTABLISH SSH CONNECTION FOR USER: domain\userid
<10.240.227.56> SSH: EXEC sshpass -d48 ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o 'User=domain\userid' -o ConnectTimeout=10 -o ControlPath=/home/userid/.ansible/cp/ansible-ssh-%h-%p-%r 10.240.227.56 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1462472936.54-168377440229444 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1462472936.54-168377440229444 `" )'"'"''
<10.240.227.59> SSH: EXEC sshpass -d49 ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o 'User=domain\userid' -o ConnectTimeout=10 -o ControlPath=/home/userid/.ansible/cp/ansible-ssh-%h-%p-%r 10.240.227.59 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/ansible-tmp-1462472936.54-274121315105946 `" && echo "` echo /tmp/ansible-tmp-1462472936.54-274121315105946 `" )'"'"''
10.240.227.59 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh.",
    "unreachable": true
}
10.240.227.56 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh.",
    "unreachable": true
}

The remote side is a RHEL 7 VM using Windows authentication, hence the "domain\userid" username.

I can connect fine using the same credentials on the command line using plain old ssh. I can also connect just fine using sshpass. And when I try to ping the hosts using ansible, the remote side's /var/log/secure shows that the password authentication succeeded.

I've confirmed that Python 2.7x is on the managed hosts.

The user I'm trying to log in as, domain\userid, is unprivileged. When I log into that box manually, I sudo su - privilegeduser with my domain\userid password, and can then sudo the rest of the way, as root or whomever.

Best Answer

Use -vvvvv (5 'v's) for full SSH debugging.