One Linux command per day (--SCP) command

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 natively, not across 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. In addition, the SCP does not account for the resources, how much system load, at this point, rsync is far less than it. Although Rsync is a bit faster than SCP, rsync can cause hard disk I/O to be very high when there are too many small files, 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 allows you to copy files and directories between Linux servers.

3. Command parameters:

-1 Mandatory SCP command using protocol SSH1

-2 Mandatory SCP command using protocol SSH2

-4 Mandatory SCP command can only use IPV4 addressing

-6 Force SCP command to use only IPV6 addressing

-B Use Batch mode (transfer password or phrase is not asked during transfer)

-C allows compression. (Pass the-c flag to SSH to turn on the compression function)

-P preserves the modification time, access time, and access rights of the source files

-Q does not display the transfer progress bar

-r recursively copy 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.

-C cipher encrypts data transfer with cipher, this option is passed directly to SSH

-F ssh_config Specifies an alternative SSH configuration file that is passed directly to SSH

-I identity_file the key file used to read the transfer from the specified file, and this parameter is passed directly to SSH

-L limit limits the bandwidth that users can use, in kbit/s

-O ssh_option If you are accustomed to using the parameter passing method in Ssh_config (5)

-P Port Note is uppercase P,port is the port number used to specify data transfer

-S program specifies the procedure used to encrypt the transfer, which must be able to understand the options of SSH (1)

4. Usage examples:

An overview of the practical application of SCP commands

Replicating from a local server to a 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 the user password is entered, the 1th only specifies the remote directory, the file name is unchanged, 2nd specified the file name

3rd, 4 does not specify a user name, the command executes after entering the user name and password, the 3rd only specifies the remote directory, the file name is not changed, 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

The 1th one specifies the user name, the command executes after the need to enter the user password;

The 2nd does not specify a user name, the command will need to enter the user name and password after execution;

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: Copying files from a distance to a local directory

Command:

SCP [Email protected]:/opt/soft/nginx-0.5.38.tar.gz/opt/soft/

Example 2: Copying from a distance to a local

Command:

scp-r [Email protected]:/opt/soft/mongodb/opt/soft/

Description: Download the MongoDB directory to the local/opt/soft/directory from the/opt/soft/on the 192.168.1.1 machine.

Example 3: Uploading a local file to a remote machine specified directory

Command:

scp/opt/soft/aaa [Email protected]:/opt/soft/aaa

Description: Copy the file AAA from the local opt/soft/directory to the OPT/SOFT/AAA directory of the remote machine 192.168.1.1

Example 4: Uploading a local directory to a remote machine-specified directory

Command: scp-r/opt/soft/aaa [Email protected]:/opt/soft/aaa

Upload local directory,/OPT/SOFT/AAA to remote machine 192.168.1.1/OPT/SOFT/AAA

One Linux command per day (--SCP) command

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.