title: Problem with authorized_keys with ansible
body: <p>I am in the process of making knots in my brain concerning a concern for rights on the <code>.ssh/authorized_keys</code>.</p>
  
  <p>I have my ansible script that works perfectly for creating my users on my servers and I just want to modify the rights of <code>/home/user</code>, <code>/home/user/.ssh</code> and finally <code>/home/user.ssh/authorized_keys</code> because they are not correct by default.
  I can't find where the problem is.</p>
  
  <pre class="lang-yml prettyprint-override"><code>---
  - hosts: all
    become: true
    tasks:
    - name: Creation groupe dev
      group:
        name: dev
        state: present
  
    - name: Creation des utilisateurs
      user:
        name: "{{ item.path }}"
        group: dev
        state: present
        password: "{{ lookup('password', '/dev/null') |password_hash('sha512') }}"
        update_password: on_create
      with_filetree: xx_pub_keys/
  
    - name: copie des clés SSH
      authorized_key:
        user: "{{ item.path }}"
        key: "{{ lookup('file', 'xx_pub_keys/' + item.path ) }}"
        state: present
      with_filetree: xx_pub_keys/
  
    - name: droits repertoires
      command:
        chmod go-w /home/{{ user.path }} &amp;&amp; \
        chmod 700 /home/{{ user.path }} &amp;&amp; \
        chmod 644 /home/{{ user.path }}/.ssh/authorized_keys
  
    - name: "Suppression des users eventuels"
      user:
        name: "{{ item.path }}"
        state: absent
        remove: true
      with_filetree: xx_pub_remove/
  
    - name: Allow admin users to sudo without a password
      lineinfile:
        dest: "/etc/sudoers"
        state: "present"
        regexp: "^%admin"
        line: "%admin ALL=(ALL) NOPASSWD: ALL"
  
    - name: restart sshd
      service: name=ssh state=restarted ...
  </code></pre>
  
  <p>So I tried in the "directory rights" section <code>user.path</code>, <code>item.path</code>, short item with <code>with_items</code> ...
  I have no idea ...</p>
  
  <p>In short, I am in favor of any correction.</p>
  
  <p>thank you in advance</p>