Rotten mud: SCP replication for centos command Learning

Source: Internet
Author: User
Tags scp command

This article is first published 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

650) This. width = 650; "Title =" clip_image001 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image001 "src =" http://img1.51cto.com/attachment/201409/18/526870_1411005665i8PD.png "width =" 664 "Height =" 141 "/>

650) This. width = 650; "Title =" clip_image002 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image002 "src =" http://img1.51cto.com/attachment/201409/18/526870_1411005665RazQ.png "width =" 1018 "Height =" 196 "/>

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

650) This. width = 650; "Title =" clip_image003 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image003 "src =" http://img1.51cto.com/attachment/201409/18/526870_1411005666eT0h.png "width =" 726 "Height =" 261 "/>

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:

650) This. width = 650; "Title =" clip_image004 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image004 "src =" http://img1.51cto.com/attachment/201409/18/526870_1411005666GThk.png "width =" 737 "Height =" 201 "/>

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

650) This. width = 650; "Title =" clip_image005 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image005 "src =" http://img1.51cto.com/attachment/201409/18/526870_1411005667vNWZ.png "width =" 707 "Height =" 398 "/>

Log on to the 192.168.1.102 server and check the copied directory. As follows:

650) This. width = 650; "Title =" clip_image006 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image006 "src =" http://img1.51cto.com/attachment/201409/18/526870_1411005667Ungc.png "width =" 723 "Height =" 214 "/>

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 ./

650) This. width = 650; "Title =" clip_image007 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image007 "src =" http://img1.51cto.com/attachment/201409/18/526870_1411005668UMtY.png "width =" 705 "Height =" 301 "/>

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 ./

650) This. width = 650; "Title =" clip_image008 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image008 "src =" http://img1.51cto.com/attachment/201409/18/526870_1411005668wHN0.png "width =" 736 "Height =" 291 "/>

650) This. width = 650; "Title =" clip_image009 "style =" border-right-width: 0px; Background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-Right: 0px; border-top-width: 0px; "Border =" 0 "alt =" clip_image009 "src =" http://img1.51cto.com/attachment/201409/18/526870_1411005669nuT0.png "width =" 516 "Height =" 169 "/>

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.

This article from the "muddy world" blog, please be sure to keep this source http://ilanni.blog.51cto.com/526870/1554609

Rotten mud: SCP replication for centos command Learning

Related Article

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.