scp utility

Using SCP to securely transfer files between remote hosts #

SCP (Secure Copy) is a command-line utility that allows you to securely transfer files between two systems using the SSH protocol. In this guide, we will walk you through the basic usage of SCP.

Syntax #

The basic syntax for using SCP is:

scp [options] [source] [destination]

where [source] is the file or directory you want to copy, and [destination] is the target location where you want to copy the file or directory to.

Options #

Here are some commonly used options for SCP:

  • -r: Recursively copy entire directories.
  • -P: Specify the SSH port to use for the connection.
  • -v: Enable verbose output for debugging.
  • -C: Compress the data during transfer to reduce the network bandwidth usage.

Examples #

Copy a file from local system to remote system #

To copy a file from your local system to a remote system, use the following command:

scp /path/to/local/file.txt user@remote:/path/to/remote/

This command will copy the file /path/to/local/file.txt to the remote system at /path/to/remote/.

Copy a file from remote system to local system #

To copy a file from a remote system to your local system, use the following command:

scp user@remote:/path/to/remote/file.txt /path/to/local/

This command will copy the file /path/to/remote/file.txt from the remote system to your local system at /path/to/local/.

Copy a directory recursively #

To copy an entire directory and its contents recursively, use the -r option:

scp -r /path/to/local/directory/ user@remote:/path/to/remote/

This command will copy the directory /path/to/local/directory/ and all its contents to the remote system at /path/to/remote/.

Conclusion #

SCP is a powerful and secure tool for transferring files between systems. By following this guide, you should now have a basic understanding of how to use SCP to transfer files between systems.