Use the SCP command on both Linux to copy files or folders

Source: Internet
Author: User
Tags file copy scp file scp command secure copy

In the past has been on the server tar packaging compression, download to the local computer, and then upload to another server, and then unzip.

In fact, you can use the SCP command directly to copy files or folders.

The SCP is secure copy, which is used for remote file copy. Data transfer uses SSH1, and the same authentication method is used with SSH1, providing the same security guarantee. Unlike RCP, the SCP will ask you to enter your password if needed.

The simplest applications are as follows:

SCP Local user name @ip address: File name 1 remote user name @ip address: file name 2

[Local User name @ip address:] Can not be entered, you may need to enter the password for the remote user name.

Several parameters that may be useful:

-V is the same as-V in most Linux commands to show progress. Can be used to view connections, authentication, or configuration errors.

-C Enable compression option.

-P Select the port. Note-P has been used by RCP.

-4 forcibly use the IPV4 address.

-6 forcibly use the IPV6 address.

Many of the parameters in the SCP are related to SSH1 and need to be looked at.

For example, copy a single file command:

SCP file

Description

File: The file name to copy

Username: User name for Telnet,

IP: Remote server IP

FilePath: Remote file path

The Copy Folder command is as follows (plus one-r parameter):

Scp-r file

=================================================================================

There are 3 common ways to copy files between different Linux:

The first is to install the FTP Server on one of the Linux servers so that you can copy it in another client program that uses FTP.

The second method is to use the Samba service, similar to the Windows file copy method to operate, relatively simple and convenient

The third is the use of SCP commands for file replication.

SCP is a file copy with security, SSH-based login. Easy to operate, for example, to copy the current file to a remote other host, you can command the following.

scp/home/1.gif [Email Protected]:/home/root

You will then be prompted to enter the login password for the root user of the other 172.19.2.75 host, and then the CP and Ungzip are started.

If you want to reverse the operation, copy the file from the remote host to the current system, it is also very simple:

SCP [Email Protected]:/home/abc.gif

The format of the Copy folder is scp-r [email protected]:/home//local Directory

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

SCP Copy and rename all files in the Copy folder and folder

The Copy folder (including the folder itself)

Scp-r/home/wwwroot/www/charts/util [Email PROTECTED]:/HOME/WWWROOT/LIMESURVEY_BACK/SCP

All files under the Copy folder (not including the folder itself)

scp/home/wwwroot/www/charts/util/* [Email PROTECTED]:/HOME/WWWROOT/LIMESURVEY_BACK/SCP

Rename the Copy file

scp/home/wwwroot/www/charts/util/a.txt [Email Protected]:/home/wwwroot/limesurvey_back/scp/b.text

——————————————————————————————————————————————————————

2 server-to-copy SCP acceleration

Today tested 2 server-to-copy, SAS disk, gigabit Network, using SCP command test, plus-C arcfour This parameter than without parameter speed half, the following is the test process

1. No parameter test results

#scp-RP 3G

3G 100% 3000MB 31mb/s 99s

2. Add parameter-C arcfour test result, the speed is one times faster

#scp-rp-c Arcfour 3G

3G 100% 3000MB 64mb/s 46s

-C Arcfour: Represents the encryption algorithm

Thank you, L. Distributed File system The brothers "three-run front teeth"

=========================

SCP error: Not a regular file

Linux local files are uploaded to the server

scp/home/liujia/file.1txt [Email Protected]:/user/liujia

Downloading files from the server

SCP [Email Protected]:/user/liujia/file1.txt/home/liujia

Command

SCP [Email protected]:/user/liujia//home/liujia

CP Error: Not a regular file

The reason is that this is equivalent to a download folder, not a file.

The solution is to add the parameter-R

scp-r [Email protected]:/user/liujia//home/liujia

That's it.

Use the SCP command on both Linux to copy files or folders

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.