Ansible authorized copy from remote source to remote destination
To append id_rsa.pub of a specific user from a remote ssh ServerA (no the controller machine ) to ServerB.


1) Fetch the public keys from ServerA

- host: ServerA
  vars:
    public_keys_dir: &lt;PUB_KEYS_DIR&gt;
    specific_user:
      - user1
      - user2
      - userN
  tasks:
    - name: Fetch pub keys
      fetch:
        src: "/home/{{ item }}/.ssh/id_rsa.pub"
        dest: "{{ public_keys_dir }}/{{ item }}-ServerA.id_rsa.pub"
        flat: yes
      loop: "{{ specific_user }}"


2) Configure authorized keys at ServerB

- host: ServerB
  vars:
    public_keys_dir: &lt;PUB_KEYS_DIR&gt;
    my_remote_user: admin
  tasks:
    - name: Set up authorized_keys
      authorized_key:
        user: "{{ my_remote_user }}"
        key: "{{ lookup('file', '{{ item }}')}}"
      with_fileglob:
        - "{{ public_keys_dir }}/*-ServerA.id_rsa.pub"


(not tested)