scp Cheat Sheet

Copy files over SSH with the trusty file-by-file tool (and when to switch to rsync).

Networking2 sections · 12 commands
⌘K

Copying Files

8
scp FILE user@host:/remote/path

Upload one file

scp -r DIR user@host:/remote/path

Upload a directory

scp user@host:/remote/FILE ./

Download a file

scp -r user@host:/remote/DIR ./

Download a directory

scp -P 2222 FILE user@host:

Specify the SSH port

scp -i KEY.pem FILE user@host:

Use a specific identity file

scp -C FILE user@host:

Enable compression

scp -o ConnectTimeout=10 FILE user@host:

Set an SSH option

Advanced

4
scp -r FILE user@host:/path && ssh user@host 'ls'

Copy then inspect on the host

scp -3 host1:FILE host2:PATH

Between two remotes via local

scp -r -- '-*.log' user@host:

Files starting with a dash

scp user@host:/etc/hosts /tmp/hosts

Grab a config file