This article was sponsored by Xiuyi linfeng and first launched in the dark world.
Due to work requirements, you need to copy the files on server a to server B. I am too lazy to build FTP and Samba servers, so I plan to use the SCP command, which is replicated through the SSH protocol.
You can view the SCP command in the help document. As follows:
SCP -- Help
Man SCP
By viewing the help documentation, we can easily find that the SCP command is very simple. The basic format of the SCP command is as follows: SCP [Options] file_source file_target
Options:
-V is the same as-V in most Linux commands to display the progress. Can be used to view connections, authentication, or configuration errors
-C enable compression options
-P Select Port
-R copy directory
We will first test the local copy of files and directories to the remote server.
Copy an object as follows:
SCP./ilanni.tar.gz [email protected]:/KS
The command is to copy the ilanni.tar.gz file under the current directory to the/KS directory of the server 192.168.1.102. Of course, during replication, you need to enter the password of the root user of the 192.168.1.102 server.
Log on to the 192.168.1.102 server and check whether the replication was successful. As follows:
You can see that the ilanni.tar.gz file has been successfully copied to the/KS directory of the 192.168.1.102 server.
The above copy is the file. Now let's test the copy directory. As follows:
SCP-R./ilanni [email protected]:/KS
Log on to the 192.168.1.102 server and check the copied directory. As follows:
Through the above and related information, we can now see that the local computer can be completely copied to the remote server through the SCP command.
Next we will start the test and copy the files and directories of the remote server to the local device.
To test a single file, run the following command:
SCP [email protected]:/KS. cfg ./
This command means to copy the KS. cfg file under the/KS directory of the server 192.168.1.102 to the current directory through the SCP command. Of course, during replication, you need to enter the password of the root user of the 192.168.1.102 server.
We can see that the KS. cfg file has been successfully copied.
The following example shows how to copy a directory from a remote server:
SCP-R [email protected]:/KS/ilanni ./
We can see that the SCP command has successfully copied all the ilanni directories in the/KS directory of the server 192.168.1.102 to the current directory.
The above describes how to use the SCP command, which is commonly used.
Rotten mud: SCP replication for centos command Learning