Remote File transfer in linux: sftp. scp, rsync, and rcp

Source: Internet
Author: User
Tags secure copy
1. scp: the scp command is the most convenient and useful command in SSH. scp is securecopy, which is used to copy remote files. Data transmission uses ssh and uses the same authentication method as ssh to provide the same security guarantee. Unlike rcp, scp is required...

1. scp: the scp command is the most convenient and useful command in SSH. scp is secure copy, which is used to copy remote files. Data transmission uses ssh and uses the same authentication method as ssh to provide the same security guarantee. Unlike rcp, scp requires you to enter a password or password for verification.
Scp [options] [local user name @ IP address:] file name 1 [remote user name @ IP address:] file name 2
-V is used to display the progress. it can be used to view the connection, authentication, or configuration error.
 
-C enable compression options.
 
-P: Select the port. Note that-p has been used by rcp.
 
-4 use the IPV4 address forcibly.
 
-6 use IPV6 addresses forcibly.
 
-R Recursively copy entire directories.
 
-P: retain some original attributes.
Example: scp-p test. sh 10.48.30.191:/root (copy the test. sh file in the current directory to the 10.48.30.191root directory)
Scp 10.48.30.191:/root/test. sh/root (copy the test. sh file under 191root to the root directory of the local machine)
2. rcp: RCP is not a secure or encrypted method of transferring files.
The rcp command has two formats. The first format is used to copy files to files. The second format is used to copy files or directories to another directory.
Rcp [options] [[user @] host1:] file1... [[user @] host2:] file2
Options:-r recursively copies all content in the source directory to the target directory. To use this option, the object must be a directory. -P tries to retain the modification time and mode of the source file, ignoring umask.
Example: rcp-p test. sh 10.48.30.191:/root (copy the test. sh file in the current directory to the 10.48.30.191root directory)
Rcp 10.48.30.191:/root/test. sh/root (copy the test. sh file under 191root to the root directory of the local machine)
3. sftp: secure file transfer protocol
Sftp has almost the same syntax and functions as ftp. S
FTP is a part of SSH and is a secure method for transferring files to the Blogger server. SFTP itself does not have a separate daemon. it must use the sshd Daemon (the default port number is 22) to complete the corresponding connection operations.
SFTP is very secure. However, because this transmission method uses encryption/decryption technology, the transmission efficiency is much lower than that of ordinary FTP. if you have higher network security requirements, you can use SFTP instead of FTP.
Example: sftp root@10.48.30.192:/root/test. sh (directly copy files on 192 to a local)
Sftp root@10.48.30.192:/root (directly connect to the 192 root directory, so you can use get put and other commands)
When using security CRT, you can use the shortcut key Alt + p to directly connect to the user's home directory in windows. You can upload the local file of windos to linux, or download the required file from linux.
4. rsync: a data Image Backup tool for unix-like systems
Images can be used to store the entire directory tree and file system. it is easy to maintain the permissions, time, and soft and hard links of the original file, and optimize the process and ensure high file transmission efficiency. You can use rcp, ssh, and other methods to transmit files. of course, you can also use a direct socket connection.
Note that rsync must be installed on server A and server B, where server A runs rsync in server mode, while server B runs rsync in client mode. In this way, The rsync daemon is run on web server A, and the client program is regularly run on B to back up the content to be backed up on web server.
Start the server:
Usr/bin/rsync -- daemon -- config =/etc/rsyncd. conf
 
This operation may require root permission.
 
/Etc/rsyncd. conf is the location of the rsyncd. conf you just edited.
 
You can also add it to/etc/rc. d/rc. local to enable the system to start automatically.
 
Start the client:
Rsync [OPTION] SRC [SRC] [USER @] HOST: DEST
Option:
-A parameter is equivalent to-rlptgoD.-r indicates recursive-l indicates a link file, which means copying a link file;-p indicates retaining the original permissions of the file;-t indicates retaining the original time of the file; -g indicates the original user group of the file,-o indicates the original owner of the file, and-D indicates a block device file;
 
-Z compression during transmission
 
-P transmission progress;
 
-V transmission progress and other information. it has something to do with-P. try it on your own. You can see the document;

Author "lovecode"

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.