# command scp in ansible

**URL:** <https://forum.ansible.com/t/command-scp-in-ansible/29953>\
**Category:** Ansible Project\
**Created:** [March 22, 2019, 12:47pm UTC](https://forum.ansible.com/t/command-scp-in-ansible/29953 "2019-03-22T12:47:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [March 22, 2019, 12:47pm UTC](https://forum.ansible.com/t/command-scp-in-ansible/29953/1 "2019-03-22T12:47:41Z")

</div>

Hi all,

I must use scp in ansible, i know module synchronize, copy but i d’ont find the module scp.  
There is junos\_scp but i d’ont know how he works 😕

Is there a way to transfer files or directories by scp as the command linux scp -rp

Thanks community ansible !! 😉

Regards,

---

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [March 22, 2019, 1:36pm UTC](https://forum.ansible.com/t/command-scp-in-ansible/29953/2 "2019-03-22T13:36:12Z")

</div>

> Hi all,
> 
> I must use scp in ansible, i know module synchronize, copy but i d'ont find  
> the module scp.  
> There is junos\_scp but i d'ont know how he works 😕
> 
> Is there a way to transfer files or directories by scp as the command linux  
> scp -rp

Not via a module. You'll need to use command for that.

- Sebastian

---

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [March 22, 2019, 3:39pm UTC](https://forum.ansible.com/t/command-scp-in-ansible/29953/3 "2019-03-22T15:39:35Z")

</div>

Hi Sebastian,

Ok.

Thanks for your answer

Regards,

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 22, 2019, 5:28pm UTC](https://forum.ansible.com/t/command-scp-in-ansible/29953/4 "2019-03-22T17:28:05Z")

</div>

The copy module uses the transfer mechanism from the 'connection  
plugin', which, if using ssh CAN be scp, but it also tries sftp and dd  
by default, but you can control this via configuration (see scp\_if\_ssh  
setting).

---

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [March 22, 2019, 6:07pm UTC](https://forum.ansible.com/t/command-scp-in-ansible/29953/5 "2019-03-22T18:07:10Z")

</div>

Hi,

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 23, 2019, 2:50am UTC](https://forum.ansible.com/t/command-scp-in-ansible/29953/6 "2019-04-23T02:50:36Z")

</div>

The copy module itself does not copy across machines, only on the same  
machine, as I said, the connection itself does the copy from  
controller to target (temp location) then executes the 'copy module'  
against that temp location (unless remote\_src=true in which case copy  
module does all the work).
