# AAP - How to copy file from remote server to local AAP

**URL:** <https://forum.ansible.com/t/aap-how-to-copy-file-from-remote-server-to-local-aap/41480>\
**Category:** Get Help\
**Tags:** aap, awx\
**Created:** [April 2, 2025, 5:27pm UTC](https://forum.ansible.com/t/aap-how-to-copy-file-from-remote-server-to-local-aap/41480 "2025-04-02T17:27:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![selvigp](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/selvigp/32/4977_2.png) [@selvigp](https://forum.ansible.com/u/selvigp)\
**Post date:** [April 2, 2025, 5:27pm UTC](https://forum.ansible.com/t/aap-how-to-copy-file-from-remote-server-to-local-aap/41480/1 "2025-04-02T17:27:58Z")

</div>

**Unable to copy files from remote server to local AAP server**.

- Running playbook via AAP (used default execution environments)
- server 1 - shared files are located (not defined in Inventory)
- server 2 - target host (defined in inventory)
- Enabled ssh connection from AAP server with user ‘test’ to server 1 with user ‘ansible’
- Playbook

```auto
- name: Fetch file from remote node
  ansible.builtin.fetch:
    src: /home/ansible/source_file.txt
    dest: /tmp/source_file.txt
    flat: yes
    become_user: ansible
  delegate_to: 'server 1'

```

- If I try to change root users to some users for localhost (where my playbook is running), getting below error.

```auto
msg: >-
  Failed to change ownership of the temporary files Ansible (via chmod nor
  setfacl) needs to create despite connecting as a privileged user. Unprivileged
  become user would be unable to read the file.
_ansible_no_log: false

```

I am facing issue to change users for localhost, so that it establish connection to server 1, Otherwise it is failing.

---

<div class="post-metadata">

**Author:** ![wayt](https://avatars.discourse-cdn.com/v4/letter/w/3be4f8/32.png) [@wayt](https://forum.ansible.com/u/wayt)\
**Post date:** [April 25, 2025, 6:00am UTC](https://forum.ansible.com/t/aap-how-to-copy-file-from-remote-server-to-local-aap/41480/2 "2025-04-25T06:00:47Z")

</div>

You may want to look at `ansible.posix.synchronize` with `mode: pull`. The task definition would be something like this:

```yaml
- name: Pull files from server 1 to server 2
  ansible.posix.synchronize:
    dest: /place/on/server2
    mode: pull
    src: rsync://server1/path/to/source

```

This would likely require you to forward an SSH agent with the private key that can access server 1 from server 2. It’s an edge case for the synchronize module but it would allow you to work with a directory if necessary. Otherwise I’d add server 1 to the inventory and have 2 plays, the first uses `fetch` to get the file(s) you want and the second uses `copy` to move them to server 2.
