Aller au contenu principal

SCP (Secure Copy)

Basic

scp [options] source destination

# copy file to server
scp file.txt arthur@192.168.1.10:/home/arthur/

# copy file from server
scp arthur@192.168.1.10:/home/arthur/file.txt .

# use SSH key
scp -i ~/.ssh/my_special_key file.txt arthur@192.168.1.10:/home/arthur/

Using with a host block

scp file.txt myserver:/home/arthur/
scp myserver:/home/arthur/file.txt

Options

-r — Copy directories recursively

scp -r mydir myserver:/home/arthur/

-P PORT — Specify an SSH port (note the capital P!)

scp -P 2222 file.txt myserver:/home/arthur/