SCP stands for Secure copy protocol. This command already available in all Linux distributions. SCP command uses to securely copy files and directories between remote hosts such as servers, network computers, etc.
SCP is based on Secure Shell (SSH), and it uses the same security concepts of ssh for ensuring security during the file transfer.
Before jump into scp examples, let’s have an idea about what are the options we can use with scp command.
Refer to scp manual page for more information.
$ man scp
scp command is now listed as deprecated. It is recommended to use the rsync command-line tool.

Helpful SCP options
-P Use to specify the ssh port. -p Preserves attributes (modification times, access times, and modes) of the original source. -q proceed without showing warning or process status. -v Show process steps, warnings, and errors. useful in debugging steps. -r recursive mode. use especially when copying directories recursively.
SCP Examples
How to copy files from localhost to a remote server
$ scp /local/path/file.txt [email protected]:/remote/path/
- NOTE: remote-host can be an IP address or a hostname
How to copy files from a remote server to localhost
$ scp [email protected]:/remote/path/file.txt /local/path/
- NOTE: remote-host can be an IP address or a hostname
How to copy directories in localhost to a remote server
$ scp -rv /local/path/directory [email protected]:/remote-path/
How to copy files from a remote server to localhost
$ scp -rv [email protected]:/remote-path/directory /local/path/
Use-q option to avoid command executing status messages and ssh warning messages.
$ scp -rq /local/path/directory [email protected]:/remote-path/

Conclusion
SCP is a handy command in work with servers related tasks. Scp command is straightforward to use because of its simplicity. However, SCP is now considered outdated and recommends using the “rsync” command or “sftp” command.
Read More:
How to Copy Files Between Linux Servers Using rsync with examples
1 comment
[…] securely through servers is a regular and important task for the system administrators. We can use SCP and rsync as primary command-line tools for achieving this kind of job. rsync (remote sync) is a […]