Linux inter-System file Transfer command--SCP

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

The SCP is a shorthand for secure copy, a command for remotely copying files under Linux, and a similar command with CP, but the CP is only copied on this machine and cannot cross the server.

And the SCP transfer is encrypted. may have a slight effect on the speed. When your server hard disk becomes read only, the SCP can help you move the files out. Other than that

The SCP is less of a resource and does not increase the amount of system load, and at this point, rsync is far less than it. Although Rsync is a little faster than the SCP, when small files are numerous,

Rsync causes hard disk I/O to be very high, and the SCP basically does not affect the normal use of the system.

1. Command format:

SCP [parameter] [original path] [Target path]

2. Command function:

SCP is the abbreviation for secure copy, and SCP is a secure remote file Copy command under the Linux system based on SSH login. The SCP command for Linux can copy files and directories between Linux servers

3. Command parameters (list several common parameters, detailed parameters can be used to view the document with the man SCP!)

-P retains the original file's modification time, access time, and access rights.

-Q does not display the transfer progress bar.

-R recursively replicates the entire directory.

-V verbose displays the output. SCP and SSH (1) will display debugging information for the entire process. This information is used to debug connections, authentication, and configuration issues.

-P "Port" note that the uppercase P,port is the port number used to specify the data transfer!

4. Usage examples:

An overview of the practical application of SCP commands:

Copy from the local server to the remote server:

(1) Copying files:

Command format:

SCP local_file [email protected]_ip:remote_folder or SCP local_file [email protected]_ip:remote_file or SCP local_file Remote_ip:remote_folder or SCP local_file remote_ip:remote_file 1th, 2 Specify the user name, the command executes after entering the user password, the 1th only specifies the remote directory, the file name is unchanged, The 2nd one specifies the file name 3rd, 4 does not specify a user name, the command executes after the user name and password, the 3rd only specifies the remote directory, the file name is unchanged, 4th specified the file name

(2) Copy directory:

Command format:

Scp-r Local_folder [email protected]_ip:remote_folder or scp-r local_folder remote_ip:remote_folder 1th A user name is specified, the command needs to be executed after execution Enter the user password, the 2nd does not specify a user name, command execution after the need to enter the user name and password;

Copy from remote server to local server:

The SCP command from remote Copy to local is identical to the one above, as long as the 2 parameters are swapped sequentially after the command copied locally to the remote.

Example 1:

[[email protected] 11]# touch scp[[email protected] 11]# lsscp[[email  protected] 11]# scp -v /root/11/scp [email protected]:/root/22          /transfer the file SCP to the/ROOT/22 directory with IP 192.168.1.112  executing: program / usr/bin/ssh host 192.168.1.112, user root, command scp -v -t / root/22openssh_5.3p1, openssl 1.0.1e-fips 11 feb 2013debug1: reading  Configuration data /etc/ssh/ssh_configdebug1: applying options for * "" [ Email protected] ' s password:                                     /Enter password   "" transferred: sent 1688, received 2128  bytes, in 0.0&Nbsp;secondsbytes per second: sent 57179.8, received 72084.5debug1: exit  status 0 [[email protected] 11]#   /View the results of the transfer/ [[email  Protected] 22]# lsscp

Instance 2: Upload the local directory to the remote machine:

[[email protected] 11]# mkdir -p test/test1/test2  Creating a directory  [[email  protected] 11]# tree testtest└── test1    └── test22  directories, 0 files[[email protected] 11]# scp /root/11/test [email  protected]:/root/22   /no-r option is passed, because no delivery information is displayed, it will wait a while before the next line is displayed  address 192.168.1.112  maps to bogon, but this does not map back to the  address - possible break-in attempt! [email protected] ' s password:                /you enter your password, you will find that the transmission error  /root/11/test: not a regular file[[email  protected] 11]# scp -r /root/11/test [email protected]:/root/22             /Plus-r option  address 192.168.1.112 maps to bogon, but this does not map back to  the address - possible break-in attempt! [email protected] ' s password:[[email protected] 11] #查看传输的结果:  [[email protected]  22]# tree testtest└── test1    └── test22 directories,  0 files[[email protected] 22]#

Example 3: Pull the directory on the remote machine:

[[email protected] 11]# scp -r /root/11/test [email protected]:/root/ 22address 192.168.1.112 maps to bogon, but this does not map  back to the address - possible break-in attempt! [email protected] ' s password:[[email protected] 11]# scp -r [email  Protected]:/root/sbin /rootaddress 192.168.1.112 maps to bogon, but this  does not map back to the address - POSSIBLE BREAK-IN  attempt! [email protected] ' s password:!                                                                100%  114     0.1kb/s    00:003.1.sh                                                            100%  736     0.7KB/s    00:003.sh                                                              100% 3090     3.0KB/s    00:001.sh                                                              100% 2743     2.7kb/s   00:002.sh                                                               100%  663     0.7kb/s   00:00[[email protected] 11 ] #查看结果: [[email protected] 11]# ls /rootanaconda-ks.cfg                  epel-release-6-8_32.noarch.rpm.1   install.log.syslog  sbin[[email protected] 11]#


This article is from the "Custom" blog, so be sure to keep this source http://zidingyi.blog.51cto.com/10735263/1725828

Linux inter-System file Transfer command--SCP

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.