# How to copy files from one server to another using Python?

The easiest way to copy files from one server to another over ssh is to use the scp command. For calling scp you'd need the subprocess module.

### For example

import subprocess
sts = os.waitpid(p.pid, 0)

You need the waitpid call to wait for the copying to complete.

Another solution is to open a ssh connection and use the scp module.

### For example

from paramiko import SSHClient
from scp import SCPClient
ssh = SSHClient()
scp.put('my_file.txt', 'my_file.txt') # Copy my_file.txt to the server