Common SCP Options
SCP (Secure Copy) is a command-line tool used to securely transfer files between a local and a remote host, or between two remote hosts, over an encrypted SSH connection. SCP is a part of the SSH (Secure Shell) suite of tools and is widely used in Linux and Unix-like operating systems.
Here are some of the common SCP options:
-
Source and Destination Paths:
scp source_file user@host:destination_path
: Copy a file from the local machine to a remote host.scp user@host:source_path destination_file
: Copy a file from a remote host to the local machine.scp user1@host1:source_path user2@host2:destination_path
: Copy a file from one remote host to another.
-
Recursive Copy:
scp -r source_directory user@host:destination_path
: Copy a directory and its contents recursively to a remote host.scp -r user@host:source_path destination_directory
: Copy a directory and its contents recursively from a remote host to the local machine.
-
Preserve File Attributes:
scp -p source_file user@host:destination_path
: Preserve the modification time, access time, and mode of the source file.
-
Verbose Output:
scp -v source_file user@host:destination_path
: Display verbose output, which can be useful for troubleshooting.
-
Limit Bandwidth:
scp -l bandwidth source_file user@host:destination_path
: Limit the bandwidth used during the file transfer.
-
Compress Data:
scp -C source_file user@host:destination_path
: Compress the data during the transfer, which can improve performance over slow network connections.
-
Port Selection:
scp -P port source_file user@host:destination_path
: Specify the port to use for the SSH connection (default is 22).
-
Identity File:
scp -i identity_file source_file user@host:destination_path
: Use the specified identity file (private key) for authentication.
-
Quiet Mode:
scp -q source_file user@host:destination_path
: Suppress progress meter and warning messages.
-
Preserve Symbolic Links:
scp -L source_file user@host:destination_path
: Preserve symbolic links during the transfer.
These are some of the most common SCP options. You can combine these options as needed to suit your specific file transfer requirements.
The SCP command is a powerful tool for securely transferring files between hosts, and understanding its various options can help you optimize your file transfer workflows. Remember to always use secure connections (SSH) when transferring sensitive data, and consider the specific requirements of your file transfer scenarios when selecting the appropriate SCP options.