Use SCP to copy files between servers under Linux (reprint)

Source: Internet
Author: User

CentOS, local server, ip:192.168.1.111
Ubuntu, remote server, ip:192.168.1.112

1. Copy the remote server's directory to the local server
Remote server 192.168.1.112 The above/tmp directory has a test directory with a file named Test and the content is test
[Email protected]:/tmp# cat Test/test
Test

Copy the directory/tmp/test the remote server 192.168.1.112 to the current directory.
[Email protected]_test_server tmp]# scp-r [email protected]:/tmp/test (server file)./(local file)
The authenticity of host ' 192.168.1.112 (192.168.1.112) ' can ' t be established.
RSA key fingerprint is 64:76:a6:1e:23:76:ec:25:5e:c2:f3:ef:fc:ad:48:7b.
Is you sure want to continue connecting (yes/no)? Yes
warning:permanently added ' 192.168.1.112 ' (RSA) to the list of known hosts.
[email protected] ' s password:
Test 100% 5 0.0kb/s 00:00

Note Copy to the local server after the formation of the directory structure for/tmp/test, rather than/tmp/tmp/test, it must be noted, here is more easily confused, after their own testing, and then encounter similar problems in the heart of the bottom.
[Email protected]_test_server tmp]# ls test/
Test

2. Copy files from the remote server to the local server
Delete the catalog test that was copied from 1.
RM-RF Test

[[Email protected]_test_server tmp]# ls-l | grep Test | Grep-v "grep"

Copy the remote server 192.168.1.112 file/tmp/test/test to the current directory.
[Email protected]_test_server tmp]# SCP [email protected]:/tmp/test/test./
[email protected] ' s password:
Test 100% 5 0.0kb/s 00:00
[[Email protected]_test_server tmp]# ls-l | grep Test | Grep-v "grep"
-rw-r--r--1 root root 5 Sep 14:07 test

3. Copy the local server directory to the remote server
Under the/tmp directory, create the directory dir111, under which the file file111 is created, and the contents are file111
[Email protected]_test_server tmp]# mkdir dir111
[Email Protected]_test_server tmp]# echo ' content111 ' > dir111/file111
[Email protected]_test_server tmp]# Cat dir111/file111
content111

Copy the local server directory dir111 to the remote server's directory/tmp

Similar to the above 1, copied to the remote server after the formation of the directory structure for/tmp/dir111, rather than/tmp/tmp/dir111, it is important to note that here is more easily confused.

Whether the copy command is scp-r dir111 [email protected]:/tmp or scp-r/tmp/dir111 [email protected]:/tmp, the directory structure generated on the remote server is the same, I have tested it myself.

[Email protected]_test_server tmp]# scp-r/tmp/dir111 [email protected]:/tmp
[email protected] ' s password:
file111 100% 0.0kb/s 00:00

Remote server 192.168.1.112 The above content
[Email protected]:/tmp# ls
dir111 Test Vmware-root
[Email protected]:/tmp# cat dir111/file111
content111

4. Copy the files from the local server to the remote server
[Email protected]_test_server tmp]# SCP dir111/file111 [email protected]:/tmp
[email protected] ' s password:
file111 100% 0.0kb/s 00:00

Remote server 192.168.1.112 The above content
[Email protected]:/tmp# ls
dir111 file111 Test Vmware-root

Use SCP to copy files between servers under Linux (reprint)

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.