If the Centos server does not have FTP, you can use scp to transfer files.

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

Scp (secure copy) 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. in windows, you can use winscp for scp file transmission. In mac, scp can be directly used for mutual transmission between linux and mac without any plug-ins.
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. port is the port number used for data transmission.
-S program
Specifies the program used for encrypted transmission. 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.

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.