I'm unable to run a playbook with public key authentication. I get this error:
Trying private key: /root/.ssh/id_dsa\r\ndebug3: no such identity: /root/.ssh/id_dsa: No such file or directory\r\ndebug1: Trying private key: /root/.ssh/id_ecdsa\r\ndebug3: no such identity: /root/.ssh/id_ecdsa: No such file or directory\r\ndebug1: Trying private key: /root/.ssh/id_ed25519\r\ndebug3: no such identity: /root/.ssh/id_ed25519: No such file or directory\r\ndebug2: we did not send a packet, disable method\r\ndebug1: No more authentication methods to try.\r\nPermission denied (publickey,password)
Till now, I have been using --ask-pass authentication, but now I need to automate it so I need to do it by public key. How have I to configure it?
I have found this playbook to do it:
---
- hosts: all
remote_user: root
vars:
authorized_key_list:
- name: root
authorized_keys:
- key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
state: present
I execute this playbook with --ask-pass and next playbook execution doesn't require password and work fine. But after some minutes it doesn't! Why? What is playbook above actually doing?
Thanks in advance.