SCP commands in Linux

Source: Internet
Author: User
Tags scp command secure copy

SCP is short for secure copy. SCP is a secure remote file copy command based on SSH login in Linux. The SCP command of Linux can copy files and directories between Linux servers.

SCP command usage:

SCP Copies files between different hosts on the network. It uses the SSH security protocol to transmit data and has the same authentication mechanism as SSH, thus securely copying files remotely.

Basic SCP command format:

SCP [-1246 bcpqrv] [-C cipher] [-F ssh_config] [-I identity_file]

[-L limit] [-O ssh_option] [-P port] [-s program]

[[User @] host1:] file1 [...] [[user @] host2:] file2

Parameters of the SCP command:

-1

Force SCP command to use protocol SSH1

-2

Force SCP command to use protocol SSH2

-4

Force SCP command to only use IPv4 addressing

-6

Force SCP command to only use IPv6 addressing

-B

Use batch processing mode (no transmission password or phrase is asked during transmission)

-C

Compression is allowed. (Pass the-C flag to SSH to enable the compression function)

-P retains the modification time, access time, and access permission of the original file.

-Q

The transmission progress bar is not displayed.

-R

Recursively copy the entire directory.

-V details display output. SCP and SSH (1) will display the debugging information of the entire process. This information is used to debug connections, verify and configure problems.

-C Cipher

Use cipher to encrypt data transmission. This option is passed directly to ssh.

-F ssh_config

Specify an alternative SSH configuration file. This parameter is passed directly to ssh.

-I identity_file

Read the key file used for transmission from the specified file. This parameter is passed directly to ssh.

-L limit

Limits the bandwidth that a user can use, in kbit/s.

-O ssh_option

If you are used to using the parameter transfer method in ssh_config (5,

-P port should be written in uppercase, and port should be the port number used for data transmission.

-S program

SpecifiesProgram. This program must be able to understand the options of SSH (1.

Application of SCP commands

1> copy from local server to remote server

(1) copy a file:

Command Format:

SCP local_file remote_username @ remote_ip: remote_folder

Or

SCP local_file remote_username @ remote_ip: remote_file

Or

SCP local_file remote_ip: remote_folder

Or

SCP local_file remote_ip: remote_file

The user name is specified for the 1st and 2nd commands. After the command is executed, enter the user password. Only the remote directory is specified for the 1st command. The file name remains the same, and the filename is specified for the 1st command.

No user name is specified for the 3 or 4 commands. After the command is executed, enter the user name and password. Only the remote directory is specified for the 3rd commands. The file name remains the same, and the file name is specified for the 4th commands.

Instance:

SCP/home/Linux/soft/scp.zip root@www.mydomain.com:/home/Linux/Others/soft

SCP/home/Linux/soft/scp.zip root@www.mydomain.com:/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 remote_username @ remote_ip: remote_folder

Or

SCP-r local_folder remote_ip: remote_folder

1st user names are specified. After the command is executed, enter the user password;

2nd user names are not specified. After the command is executed, enter the user name and password;

Example:

SCP-r/home/Linux/soft/root@www.mydomain.com: // 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, that is, the remote server will have the/home/Linux/Others/soft/directory

2> copy from remote server to local server

The SCP command remotely replicated to the local device is the same as the command above. You only need to swap the order of the two parameters after the command locally copied to the remote device.

For example:

SCP root@www.mydomain.com:/home/Linux/soft/scp.zip/home/Linux/Others/scp.zip

SCP www.mydomain.com:/home/Linux/soft/-r/home/Linux/Others/

In Linux, many parameters in the SCP command are related to SSH1. You also need to see more original parameter information. You can run man SCP to see more detailed instructions in English.

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.