Security

SCP CLI

SCP commands for secure file transfer over SSH.

20 commands
Windows MacOS Linux
#file-transfer #remote

Basic Transfer

Copy local file to remote host
scp file.txt user@host:/path/
Copy remote file to local machine
scp user@host:/path/file.txt .
Copy file to remote home directory
scp file.txt user@host:~/
Copy remote file to local tmp
scp user@host:~/file.txt /tmp/

Directory Transfer

Copy directory recursively to remote
scp -r ./mydir user@host:/path/
Copy remote directory to local
scp -r user@host:/path/dir ./local/
Copy source tree to remote project
scp -r ./src user@host:~/project/

Options

Use custom SSH port
scp -P 2222 file.txt user@host:/path/
Use specific identity key file
scp -i ~/.ssh/mykey file.txt user@h:/
Enable compression during transfer
scp -C file.txt user@host:/path/
Limit bandwidth in Kbit per second
scp -l 1000 file.txt user@host:/path/
Enable verbose output for debugging
scp -v file.txt user@host:/path/
Suppress progress meter and warnings
scp -q file.txt user@host:/path/

Advanced

Copy between two remote hosts via local
scp -3 user@h1:/f.txt user@h2:/path/
scp -o StrictHostKeyChecking=no f u@h:/ # Skip host key verification
Preserve modification times and modes
scp -p file.txt user@host:/path/
Copy remote file with spaces in name
scp user@host:"/path/my file.txt" .

Quick Commands

Copy a local file to a remote host over SSH
scp file.txt user@host:/path/
Recursively copy a directory to a remote host
scp -r ./dir user@host:/path/
Copy file using a custom SSH port
scp -P 2222 file.txt user@host:/path/