Linux SCP command Remote copy copy large data Web site file Quick Move Command example

Source: Internet
Author: User
Tags ssh vps scp command vps server


If the data file is larger, rely solely on the compression, transfer and other processes are also feasible, in fact, we can use the SCP command to drag between servers, this is our Linux servers in the Web site data file Drag transfer, and do not need to compress directly to the specified directory all the files are dragged over, For example, the data file has several GB, by packaging compression, drag decompression more time-consuming, direct use of the SCP command is very simple to achieve.




Our familiar CP commands only fit the replication transfer between the directories of the current VPS server, and the SCP can make remote copies of files between servers, faster, and the transfer process is encrypted. In this article, Chiang will organize and rehearse the common commands for the SCP command so that it can be used when a data migration copy of a large file site is encountered.





First, basic use of SCP




The code is as follows

SCP [parameters] [Original path] [Target path]




Second, the SCP common parameters and notes




The code is as follows

-1 Mandatory SCP command use protocol SSH1

-2 Mandatory SCP command use protocol SSH2

-4 Force the SCP command to use only IPV4 addressing

-6 Force the SCP command to use only IPV6 addressing

-B Use Batch mode (transfer password or phrase not queried during transmission)

-C allows compression. (Pass the-c flag to SSH to turn on the compression feature)

-P retains the original file modification time, access time and access rights

-Q do not show transfer progress bar

-R recursively copies the entire directory

-V Displays the output in verbose mode. SCP and SSH (1) will display debugging information for the entire process. This information is used to debug connections, verify, and configure issues

-C cipher to cipher data transfer, this option will be passed directly to SSH

-F ssh_config Specifies an alternate SSH configuration file, which is passed directly to SSH

-I identity_file the key file used to read the transfer from the specified file, which is passed directly to the SSH

-L limit limits the bandwidth that the user can use, in kbit/s units.

If the-O ssh_option is accustomed to using parameter passing in Ssh_config (5),

-P Port Note is uppercase P, port is the port number used to specify the data transfer

-S program specifies the programs to use when encrypting the transmission. This program must be able to understand the options for SSH (1)




Iii. examples of common usages of SCP commands




A-Copy the current file to the remote server directory




The code is as follows

SCP [Current file] [remote server user @ Remote server ip]:[remote server directory]




Demonstration cases:




The code is as follows

SCP Itbulu.com.txt root@121.54.xxx.xxx:/root/




Explanation: Remote copies of the Itbulu.com.txt files in the current directory of the current VPS server are sent to the 121.54.XXX.XXX server/root/directory.







In the process of execution we need to determine the yes/no, whether to perform the transfer, I am sure to enter Yes and return, and then prompt to enter the remote server's root username password, and then execute the copy.




B-Copy the current folder/directory to the remote server directory




The code is as follows

Scp-r [current Server Web directory/folder] [root@ remote server IP address]:[remote server directory]




Demonstration cases:




The code is as follows

Scp-r/root/mini/root@121.54.xxx.xxx:/root/itbulu




Explanation: Copies all contents of the/mini/folder in the current directory to the/root/itbulu/directory in the remote server.







In the execution process, we need to enter the remote server's root password and then enter the execution, depending on how much of our file data and the transmission speed between the decision how long it will take to complete the transmission.




C-Copy the remote server's content/files to the local current server




1. copy files to Local




The code is as follows

SCP [root@ remote server IP address]:[remote server directory file] [current Server Web directory/folder]




Demonstration examples:




The code is as follows

SCP root@121.54.xxx.xxx:/soft/itbulu.com.tar.gz/soft/




In fact, it is very simple, we can see as long as the above upside down.




2. Copy Directory to Local




The code is as follows

scp-r [root@ remote server IP address]:[remote server directory] [current server Web directory/folder]




Demonstration examples:




The code is as follows

Scp-r root@121.54.xxx.xxx:/root/itbulu/root/mini/




Iv. SCP command Copy and copy Web site catalog Summary




The old Chiang collated and shared the common usage of the SCP command, as well as several common examples, so that when we move the site data, we do not need to copy to the local, and then the local upload such a complex process. The SCP command can be used for remote upload and transfer directly to the corresponding directory, and the process is encrypted and fast.

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.