SCP (secure copy) is a command-line utility that allows you to securely copy files and directories between two locations.
scp, you can copy a file or directory:
- From your local system to a remote system.
- From a remote system to your local system.
- Between two remote systems from your local system.
SCP copies files between hosts on a network. It uses SSH for data transfer, and uses the same authentication and provides the same security as SSH. SCP will ask for passwords or passphrases if they are needed for authentication.
When copying a source file to a target file which already exists, SCP will replace the contents of the target file. If the target file does not yet exist, an empty file with the target file name is created, then filled with the source file contents.
SCP Command Syntax
scp command syntax take the following form:
OPTION– scp options such as cipher, ssh configuration, ssh port, limit, recursive copy …etc.
[[email protected]]SRC_HOST:]file1– Source file.
[[email protected]]DEST_HOST:]file2– Destination file
Local files should be specified using an absolute or relative path while remote file names should include a user and host specification.
The colon (
:) is how
scp distinguish between local and remote locations.
scp provides a number of options that control every aspect of its behavior. The most widely used options are:
-PSpecifies the remote host ssh port.
-pPreserves files modification and access times.
-qUse this option if you want to suppress the progress meter and non-error messages.
-C. This option will force
scpto compresses the data as it is sent to the destination machine.
-rThis option will tell
scpto copy directories recursively
If you are on the computer from which you want to send a file to a remote computer:
scp /file/to/send [email protected]:/where/to/put
remote can be a domain name or an IP address.
On the other hand, if you are on the computer wanting to receive a file from a remote computer:
scp [email protected]:/file/to/send /where/to/put
scp can also send files between two remote hosts:
So the basic syntax is:
For more details read Linux man page