Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ansible SSH too many authentication failures

This exception appears to affect ansible when a playbook is executed from a host with several identities configured in the SSH agent (Tested on a development machine with 12 private keys).

I've noted this exception to be particulary common with AWS targets

Inventory configuration

Most tasks will run fine when we configure our inventory to use a specific private key.

We also need to set the IdentitiesOnly flag so that ssh does not attempt other authentication strategies.

# inventory ansible_ssh_private_key_file=/a/b/key.pem ansible_ssh_extra_args="-o IdentitiesOnly=yes"

Fixing synchronize module tasks

synchronize tasks will require an additional flag:

use_ssh_args needs to be set to include ssh arguments from the inventory when running rsync

    - name: copy code
        src: "<source>"
        dest: "<destination>"
        use_ssh_args: yes
        - code

See synchronize module options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.