- 8777701917
- info@saikatinfotech.com
- Basirhat W.B
In the context of Linux, SCP stands for Secure Copy Protocol. It is a command-line tool used for securely transferring files or directories between computers over a network, typically using the SSH (Secure Shell) protocol for encryption. SCP is widely used in Linux and other Unix-like systems for copying files between local and remote machines or between two remote machines.
Basic Syntax:
bash
scp [options] [source] [destination]
[options]: Optional flags to modify the behavior of SCP.
[source]: The file or directory to be copied. This can be a local file or a remote file (with a user and host).
[destination]: The location where the file should be copied to. This can also be a local or remote destination.
Examples:
Copying a file from a local machine to a remote server:
bash
scp /path/to/local/file username@remote_host:/path/to/remote/directory
This copies file from the local machine to the specified
directory on the remote server.
Copying a file from a remote server to the local machine:
bash
scp username@remote_host:/path/to/remote/file /path/to/local/directory
This retrieves file from the remote server to the local machine.
Copying an entire directory Folder (with -r option for recursion):
bash
scp -r /path/to/local/directory username@remote_host:/path/to/remote/directory
The -r flag is used to copy entire directories recursively.
Copying between two remote servers:
bash
scp username@remote_host1:/path/to/file username@remote_host2:/path/to/destination
This command copies a file from one remote server to another.
Common Options:
-r: Recursively copy entire directories.
-P: Specify a custom SSH port (note the uppercase P).
-i: Specify a private key file for authentication.
-v: Enable verbose mode to see more detailed output for debugging.
-C: Enable compression to speed up the transfer for large files.
Example of using SCP with a private key:
bash
scp -i /path/to/private_key.pem /path/to/local/file username@remote_host:/path/to/remote/directory
Conclusion:
SCP is a powerful and easy-to-use tool for secure file transfers in Linux and other systems. It is widely used for tasks like backing up files, copying files between servers, and transferring data securely over a network.