scp (secure copy) command in Linux system is used to copy file(s) between servers in a secure way. The SCP command or secure copy allows secure transferring of files in between the local host and the remote host or between two remote hosts. It uses the same authentication and security as it is used in the Secure Shell (SSH) protocol. SCP is known for its simplicity, security and pre-installed availability.
scp [-346BCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 … [[user@]host2:]file2
- scp –P port: Specifies the port to connect on the remote host.
- scp –p: Preserves modification times, access times, and modes from the original file.
- scp –q: Disables the progress meter.
- scp –r: Recursively copy entire directories.
- scp –S program: Name of program to use for the encrypted connection. The program must understand ssh(1) options.
- scp –v: Verbose mode. Causes scp and ssh to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems.
- Copying file without the “-C” parameter will result in 1671.3 second delay. You may compare the result to the command below which is using the “-C” parameter.
As you can see, whenever you are using compression, the transfer process is being done in 172.5 seconds. It is 10 times faster than not using the “-C” parameter. If you are copying a lot of files across the network, “-C” parameter would definitely be going to help you to decrease the total time you need.
- Select another cipher as to encrypt files: By default, SCP is using the “AES-128” to encrypt files. If you want to change to any another cipher to encrypt it, you can use that by using “-c” parameter.
- To specify a specific port to use with SCP: Usually, SCP is using port 22 as a default port. But for security reason, you can change the port into another port. For example, we are going to use port 2249. Then the command needs to be like this.
scp -P 2249 Label.pdf email@example.com:.
As you can see, after you enter the password, there is no information about the SCP process. After the process is complete, you will see a prompt again. If you want the detailed information of the SCP process, then -v parameter helps you out.
scp -v Label.pdf firstname.lastname@example.org:.
- Limiting bandwidth usage: Another parameter that may be proven useful is “-l” parameter. The “-l” parameter will limit the total bandwidth to use. It will be useful if you made an automation script to copy a lot of files, but you don’t want the bandwidth to be drained by the SCP process.
scp -l 400 Label.pdf email@example.com:.
If you want to provide modification times, access times, and modes from original files then “-p” parameter will help you on this. Estimated time and the connection speed will be going to appear on the screen.
scp -p Label.pdf firstname.lastname@example.org:.