Search code examples
sshansiblepublic-keyopenssh

Ansible SSH passwd authentication successful, but publickey authentication fails


When using ansible, I authenticate using the following parameters:

-u bob -k -K -b 

I get the output I want, but it turns out that Ansible fails publickey authentication on each system.

Selected output from /var/log/secure on one of the recipient systems:

Failed publickey for bob from $IP port $PORT ssh2

Accepted password for bob from $IP port $PORT ssh2     

I'm making my through the documentation, but I have yet to find a method to prevent Ansible from attempting to use anything other than just passwd authentication.

Any help is appreciated.


Solution

  • Add SSH client option -o PreferredAuthentications=password where applicable (Ansible inventory, extra-variables, ssh-config, etc.).

    For example, for hosts file:

    [myhosts]
    host1 ansible_host=X.X.X.X ansible_ssh_extra_args="-o PreferredAuthentications=password"