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.txtOptions and examples
-P portCommonUse the specified SSH port. Uppercase P specifies the port.
scp -P 2222 ./report.txt alice@server.example.com:~/-i identity_fileCommonUse the specified private key for authentication.
scp -i ~/.ssh/id_ed25519 ./report.txt alice@server.example.com:~/-rCommonCopy directories recursively. Review the source and destination before overwriting files.
scp -r ./reports alice@server.example.com:~/-pCommonPreserve modification and access times and file modes where possible. Lowercase p does not set the port.
scp -p ./report.txt alice@server.example.com:~/-J destinationConnect through the specified jump host.
scp -J alice@bastion.example.com ./report.txt alice@internal.example.com:~/-o optionPass an SSH client configuration option.
scp -o ConnectTimeout=10 ./report.txt alice@server.example.com:~/-CRequest SSH compression.
scp -C ./report.txt alice@server.example.com:~/-l limitLimit bandwidth in kilobits per second.
scp -l 1024 ./report.txt alice@server.example.com:~/-vShow connection diagnostics; output can contain sensitive details.
scp -v ./report.txt alice@server.example.com:~/-OUse the legacy SCP protocol for compatibility when necessary. Modern OpenSSH uses SFTP by default.
scp -O ./report.txt alice@server.example.com:~/Authoritative references
Reviewed October 27, 2026