scp

Copy files over an SSH connection.

Before you run

-P (uppercase) selects the port; lowercase -p preserves file times and mode. OpenSSH 9.0 and newer use SFTP by default, so server SFTP support matters. Transfers can overwrite destination files: choose names deliberately. These examples assume report.txt exists; paths and quoting differ on Windows.

Examples

Upload a local file to the remote account’s home directory.

scp -P 2222 ./report.txt alice@server.example.com:~/

Download the remote file under a new local name.

scp -P 2222 alice@server.example.com:~/report.txt ./report-downloaded.txt

Options and examples

-P portCommon

Use the specified SSH port. Uppercase P specifies the port.

Example
scp -P 2222 ./report.txt alice@server.example.com:~/
-i identity_fileCommon

Use the specified private key for authentication.

Example
scp -i ~/.ssh/id_ed25519 ./report.txt alice@server.example.com:~/
-rCommon

Copy directories recursively. Review the source and destination before overwriting files.

Example
scp -r ./reports alice@server.example.com:~/
-pCommon

Preserve modification and access times and file modes where possible. Lowercase p does not set the port.

Example
scp -p ./report.txt alice@server.example.com:~/
-J destination

Connect through the specified jump host.

Example
scp -J alice@bastion.example.com ./report.txt alice@internal.example.com:~/
-o option

Pass an SSH client configuration option.

Example
scp -o ConnectTimeout=10 ./report.txt alice@server.example.com:~/
-C

Request SSH compression.

Example
scp -C ./report.txt alice@server.example.com:~/
-l limit

Limit bandwidth in kilobits per second.

Example
scp -l 1024 ./report.txt alice@server.example.com:~/
-v

Show connection diagnostics; output can contain sensitive details.

Example
scp -v ./report.txt alice@server.example.com:~/
-O

Use the legacy SCP protocol for compatibility when necessary. Modern OpenSSH uses SFTP by default.

Example
scp -O ./report.txt alice@server.example.com:~/

Authoritative references

Reviewed October 27, 2026