An explanation of SCP commands under Linux

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

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.

Usefulness of the SCP command:

SCP copies files between different hosts on the network, transmits data using SSH security protocols, and has the same authentication mechanism as SSH to secure remote copy files.

SCP Command basic format:

SCP [ -1246BCPQRV] [-C cipher] [-f ssh_config] [-I identity_file]

[-L limit] [-O ssh_option] [-P Port] [-S program]

[[Email protected]]host1:]file1 [...] [[Email Protected]]host2:]file2

Parameter description for SCP command:

-1

Enforce SCP command using protocol SSH1

-2

Enforce SCP command using protocol SSH2

-4

Force SCP command to use only 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

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

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

-Q

The transfer progress bar is not displayed.

-R

Recursively replicate 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.

-C cipher

The data transfer is encrypted with cipher, and this option is passed directly to SSH.

-F Ssh_config

Specifies an alternate SSH configuration file that is passed directly to SSH.

-I. Identity_file

The key file used to read the transfer from the specified file, which is passed directly to SSH.

-L Limit

Limit the bandwidth that the user 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 specified for data transfer

-S Program

Specifies the program that is used to encrypt the transfer. This program must be able to understand the options for SSH (1).

Practical application of SCP command

1> copying 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

Instance:

scp/home/linux/soft/scp.zip [Email Protected]:/home/linux/others/soft

scp/home/linux/soft/scp.zip [Email Protected]:/home/linux/others/soft/scp2.zip

Scp/home/linux/soft/scp.zip Www.mydomain.com:/home/linux/others/soft

Scp/home/linux/soft/scp.zip Www.mydomain.com:/home/linux/others/soft/scp2.zip

(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;

Example:

Scp-r/home/linux/soft/[Email protected]:/home/linux/others/

Scp-r/home/linux/soft/www.mydomain.com:/home/linux/others/

The above command copies the local soft directory to the remote others directory, which will have the/home/linux/others/soft/directory on the remote server after replication

2> copying from a remote server to a 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.

For example:

SCP [Email Protected]:/home/linux/soft/scp.zip/home/linux/others/scp.zip

SCP www.mydomain.com:/home/linux/soft/-r/home/linux/others/

Many parameters of SCP command in Linux system are related to SSH1, also need to see more original parameter information, can run man SCP to see more detailed English explanation.

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.