A detailed explanation of SCP command usage in Linux (transmission speed)

Source: Internet
Author: User
Tags hash scp command


SCP command

The SCP can replicate files between 2 Linux hosts;

Command basic format:
SCP [Optional parameters] File_source File_target

= = =
Copy from local to remote
= =
* Copy file:
        * command format:
 &NB sp;              SCP Local_file Remote_ Username@remote_ip:remote_folder
                 or
                 SCP local_file remote_username@remote_ip:remote_file
                 or
                 SCP local_file remote_ip:remote_folder
                 or
                 SCP local_file remote_ip:remote_file

1th, 2 specified the user name, the command needs to enter the password after the execution, the 1th specified only the remote directory, the file name unchanged, the 2nd specified the filename;
3rd, 4 did not specify the user name, the command needs to enter the user name and password, the 3rd specified only a remote directory, the file name unchanged, the 4th specified the filename;
Example
Scp/home/space/music/1.mp3 Root@www.cumt.edu.cn:/home/root/others/music
Scp/home/space/music/1.mp3 Root@www.cumt.edu.cn:/home/root/others/music/001.mp3
Scp/home/space/music/1.mp3 Www.cumt.edu.cn:/home/root/others/music
Scp/home/space/music/1.mp3 Www.cumt.edu.cn:/home/root/others/music/001.mp3

* Copy directory:
* Command format:
Scp-r Local_folder Remote_username@remote_ip:remote_folder
Or
Scp-r Local_folder Remote_ip:remote_folder

The 1th specifies the user name, the command needs to enter the password after the execution;
The 2nd does not specify the user name, the command needs to enter the user name and password after execution;
Example
Scp-r/home/space/music/root@www.cumt.edu.cn:/home/root/others/
Scp-r/home/space/music/www.cumt.edu.cn:/home/root/others/

The above command copies the local music directory to the remote others directory, which is remotely available after replication. /others/music/Directory


======
From remote replication to local
======
From remote to local, as long as the following 2 parameters of the command will be copied from the local to the remote order can be replaced;

For example:
SCP Root@www.cumt.edu.cn:/home/root/others/music/home/space/music/1.mp3
Scp-r www.cumt.edu.cn:/home/root/others//home/space/music/

The simplest applications are as follows:

SCP Local username @IP address: filename 1 remote username @IP address: filename 2

[Local username @IP address:] You may need to enter the password for the remote user name without entering it.

Several parameters that may be useful:

-V is the same as the-V meaning in most Linux commands, and is used to show progress. Can be used to view connections, authentication, or configuration errors.

-C enables compression options.

-P Select the port. Note-P has been used by RCP.

-4 forcibly use IPV4 address.

-6 forcibly use IPV6 address.

Note two points:
1. If the remote server firewall has special restrictions, the SCP will go to the special port, specific port depending on the situation, the command format is as follows:
#scp-P 4588 remote@www.abc.com:/usr/local/sin.sh/home/administrator
2. Use the SCP to be aware of whether the user you are using has permission to read the appropriate files for the remote server.


Accelerate SCP transfer speed


Conclusion
Disclaimer: The test data given here are not generic and are for informational purposes only. Testing has a lot to do with the characteristics of the data itself, this article uses the InnoDB redo log as the test data.

* Change SSH encryption algorithm, can make faster; Usually, the weaker the encryption algorithm, the faster

* Usually compression reduces the speed of the SCP, but it has a lot to do with data types, compression is enabled for data with very high compression rate, and can accelerate

* Compression level has little impact on transmission efficiency

* Different MAC (message authentication code) algorithms for integrity checking have an impact of about 10% to 20% performance.

So, simply try the following to get your SCP speed double:

Scp-r-C arcfour128 ...
Scp-r-C AES192-CBC ...
Scp-r-C Arcfour128-o "MACs umac-64@openssh.com" ... Note: Enable compression using parameters:-o "Compression yes"

2. Test data: Encryption algorithms and the impact of compression
This compares the encryption algorithms implemented in 12 SSH implementations and the use of compressed transmission efficiency. The test file uses the InnoDB 1gb*4 log file (note: Different types of file test results will be very different), where the ordinate unit is MB/s, the data is divided into compressed transmission and uncompressed transmission of the two groups:

Raw data: Scp_speed.txt


It can be seen that the transmission speed of different encryption algorithms is very large, the use of compression, speed down a lot, but also see the different encryption algorithm after the difference is not very small.

3. About whether to enable compression
* Compression only in the network transmission speed is very slow, so that the compressed after the save time is greater than the compression itself time, then only effect, so whether to enable compression, the actual test

* Compress low data, do not enable compression (such as compressed data, video, etc.)

* It is usually recommended to compress before transmission, instead of using SSH compression; it is recommended to use parallel compression tools such as PIGZ/LBIZP2

* A large number of duplicates, holes in the data, this kind of data suitable for compression, you can try to compress the options, such as the following is a group, a large number of "empty" data test:

See, compression greatly improves transmission efficiency.

4. "Compression level" has little impact on transmission speed
The last set of comparisons is to change the compression level from 1 to 9, compared to the transmission speed, ordinate units MB/s, 12 encryption algorithms using the test 9 compression level, the data are as follows:

Large Map link raw data: scp-compression-level.txt

As you can see, the compression level has less impact on the transport. The default compression level used by SSH is 6.

5. Test data: Integrity check algorithm Macs selection
With the option Macs can set the corresponding hashing algorithm, the man Ssh_config can see which hashing algorithms are supported. Here's a comparison of the performance of the use-Free integrity check algorithm under 12 encryption algorithms:

See, the "umac-64@openssh.com" (for this hash) performance is better in most cases, so it is recommended that you try this hash algorithm to verify that the speed and elevation of your scenario are the same. You can also see that the default HMAC-MD5 hashes perform better under the default encryption aes128-ctr;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.