Linux uses SCP to implement server A to transfer files to server B _linux

Source: Internet
Author: User
Tags file copy server port

The SCP is a security file copy, based on SSH login. Easy to operate, such as to the current one file copy to a remote other host, you can command the following.

Copy Code code as follows:
Scp/home/daisy/full.tar.gz Root@172.19.2.75:/home/root

You will then be prompted to enter the login password for the other 172.19.2.75 host's root user, and then copy it.

If you want to reverse the operation, it is also easy to copy the files from the remote host to the current system.

Copy Code code as follows:
SCP root@172.19.2.75:/home/root/home/daisy/full.tar.gz

This article illustrates the implementation process of file transfer between Linux servers for your reference, the specific contents are as follows

1.1 Normal transmission files, do not need to connect Server B through the Proxy service, log in to Server A, execute
SCP Test.sql User@server-b:path
Note: Transfer file Test.sql to Server B (user name for Server B, server-b to Server B ip,path to the path of the specified receive file on Server B), enter user password

1.2 Need to access server B via proxy, execute

Scp-oproxycommand= ' nc-v-xproxy:port%h%p ' Test.sql User@server-b:path
Description: Proxy is ip,port as proxy server port, enter user's password for carriage return

In addition, you can use the SFTP command, the format is basically the same:

Sftp-oproxycommand= ' nc-v-xproxy:port%h%p ' user@server-b port
Description: The latter port is the ports of server B

1.3 Transferring files using the SCP

1), download files from the server
SCP username@servername:/path/filename/tmp/local_destination

For example, the SCP codinglog@192.168.0.101:/home/kimi/test.txt downloads/home/kimi/test.txt files on 192.168.0.101 to/tmp/local_ Destination
2), upload local files to the server
Scp/path/local_filename Username@servername:/path

For example, scp/var/www/test.php codinglog@192.168.0.101:/var/www/the test.php file in the native/var/www/directory
Upload to the/var/www/directory on the 192.168.0.101 server
3), download the entire directory from the server
Scp-r username@servername:remote_dir//tmp/local_dir

For example: Scp-r codinglog@192.168.0.101/home/kimi/test/tmp/local_dir
4), upload directory to the server
Scp-r/tmp/local_dir Username@servername:remote_dir

For example:
Scp-r test codinglog@192.168.0.101:/var/www/upload the test directory in the current directory to the server/var/www/directory

The above is the Linux implementation Server A to Server B transmission of the entire contents of the file, I hope that you learn how Linux server between the file transfer has been inspired.

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.