Forever & AlwaysLINUX COMMAND ATLAS

LINUX COMMAND ATLAS · COMMAND GUIDE

Linux scp command

Copy files between hosts over SSH. Check both source and destination paths.

OpenSSH

Syntax

Command form
scp [OPTION]... SOURCE... TARGET

Common options

6 options
OptionWhat it does
-rCopy directories recursively.
-P PORTConnect to the SSH server on PORT (uppercase P).
-i IDENTITY_FILESelect the private key file.
-pPreserve modification times, access times and modes.
-CEnable compression during transfer.
-qSuppress progress and diagnostic messages.

Usage examples

3 examples

Copy files between hosts over SSH. Check both source and destination paths.

scp ./report.txt user@host:/tmp/

Copy a local file to a remote directory.

scp report.txt alice@example.com:/tmp/

Copy a directory tree using a custom SSH port.

scp -P 2222 -r ./site alice@example.com:/srv/backup/

Notes

Modern OpenSSH scp uses SFTP by default. Quote remote paths containing spaces and confirm the destination before transferring.