Changing a server or adding a server often uses a copy of the file between two servers, which allows you to use the SCP command.
The SCP is a shorthand for secure copy, a command for remotely copying files under Linux, and a similar command with CP, although the CP is only copied natively and cannot cross the server, and the SCP transfer is encrypted. may have a slight effect on the speed.
Copying files between two hosts must have a replication execution account and operation permissions for two hosts at the same time.
SCP generally has six ways to use:
Locally copied remote files: (copy remote files to local)
SCP [Email protected]:/val/test/test.tar.gz/val/test/test.tar.gz
Remote replication of local files: (Copy Local files to remote host)
scp/val/test.tar.gz [Email protected]:/val/test.tar.gz
Local Replication remote directory: (copy remote directory to local)
SCP [Email protected]:/val/test//val/test/
Remote Replication Local directory: (copy the local directory to the remote host)
scp/val/[Email protected]:/val/
Locally copied remote files to the specified directory: (copy remote files to local)
SCP [Email protected]:/val/test/test.tar.gz/val/test/
Remotely copy local files to the specified directory: (copy Local files to the remote host)
scp/val/test.tar.gz [Email protected]:/val/
Note: When you specify a file or directory, the previous one is the file or directory that you want to copy, and the next one is specifying where to copy it. Such as:
scp/val/test.tar.gz [Email protected]:/val/test.tar.gz
In the front/val/test.tar.gz is the file to be copied, after [email protected]:/val/test.tar.gz is the specified copy to where and the corresponding file name. If the two swap is the opposite of the function.
When files that have multiple servers at the same time are copied to the local directory:
SCP [email protected]:/var/cp1.tar.gz [Email protected]:/var/cp2.tar.gz/var/tmp/
Note: The last one is required to be a directory, the previous must be a file, in order to successfully bulk copy, the replication will prompt you to enter the password multiple times.
[Email protected] ~]# SCP--help
USAGE:SCP [ -1246BCPQRV] [-C cipher] [-f ssh_config] [-I identity_file]
[-L limit] [-O ssh_option] [-P Port] [-S program]
[[Email Protected]]host1:]file1 ... [[Email Protected]]host2:]file2
Command parameters:
-1 Mandatory SCP command using protocol SSH1
-2 Mandatory SCP command using protocol SSH2
-4 Force SCP command to use only IPV4 addressing
-6 Force SCP command to use only IPV6 addressing
-B Use Batch mode (transfer password or phrase is not asked during transfer)
-C allows compression. (Pass the-c flag to SSH to turn on the compression function)
-P retains the original file's modification time, access time, and access rights.
-Q does not display the transfer progress bar.
-R recursively replicates the entire directory.
-V verbose displays the output. SCP and SSH (1) will display debugging information for the entire process. This information is used to debug connections, authentication, and configuration issues.
-C cipher encrypts the data transfer with cipher, and this option is passed directly to SSH.
-F ssh_config Specifies an alternative SSH configuration file that is passed directly to SSH.
-I identity_file the key file used to read the transfer from the specified file, and this parameter is passed directly to SSH.
The-L limit limits the bandwidth that the user can use, in kbit/s.
-O ssh_option If you are accustomed to using the parameter passing method in Ssh_config (5),
-P Port Note is uppercase P, port is the port number specified for data transfer
-S program specifies the programs that are used to encrypt the transmission. This program must be able to understand the options for SSH (1).
This article is from the "gangbusters" blog, make sure to keep this source http://php2012web.blog.51cto.com/5585213/1614282
Copy files between linux two servers SCP