Forcing Ansible to use SSH password

Viewed 122

I'm trying to use Ansible to set up hosts that will initially only be accessible via SSH with a password (not a key file) (yes, my first playbook is to set up key based access).

I can access the hosts using SSH passwords from the command line.

Running Ansible in verbose mode gives the following output

EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="debian"' -o ConnectTimeout=30 -o ControlPath=/home/home/.ansible/cp/2d22e058dc 192.168.122.11 '/bin/sh -c '"'"'echo ~debian && sleep 0'"'"''
<192.168.122.11> (255, b'', b'OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /home/home/.ssh/config
...
debug3: no such identity: /home/home/.ssh/id_dsa: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
debian@192.168.122.11: Permission denied (publickey,password).

It looks like the SSH client is being forced to not use passwords PasswordAuthentication=no and there is nothing in the rest of the output that indicates it is trying.

This is my hosts file (no they are not the real passwords)

all:
  children:
    init:
      hosts:
        bullseye-apps:
        bullseye-backup:
      vars:
        ansible_ssh_pass: 'password'
        ansible_become_pass: 'password'

So I think I should be giving Ansible the option to use passwords.

I run my playbook as follows

ansible-playbook -i test-hosts.yml playbook.yml

I've recently upgraded my OS (to Pop_OS! 22.04) and haven't run these playbooks in a while so possibly a change in Ansible?

$ ansible --version
ansible 2.10.8
  config file = /home/home/Projects/federated-agency/ansible.cfg
  configured module search path = ['/home/home/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0]

Any thoughts?

1 Answers

So it looks like I misspelled the user names of one of the hosts, damnit!

Related