There are 3 common ways to copy files between different Linux:
The first is FTP, which is one of the Linux installation FTP Server, so you can use an FTP client program to copy files.
The second method is to use Samba services, similar to the Windows file copy method to operate, relatively simple and convenient.
The third is the use of SCP commands for file replication.
The SCP command for Linux can be used to copy files and directories between Linux, and is a security file copy, SSH-based login.
There are two ways to use SCP:
1. Copy the local directory or file to a remote host on another computer:
A. Copying files
#scp [Local User name @ip address:] File name 1 remote user name @ip address: file name 2
Example: Copy the A.txt file under local/root/zbdata to the/root/zbdata/directory of the remote host 10.1.11.210
#scp/root/zbdata/a.txt [Email protected]:/root/zbdata/
If you see that you need to enter the password for the remote host user name, you can copy it successfully
B. Copy Directory
#scp-R [local user name @ip address:] Directory name remote user name @ip address: directory name
Example: Copy the local/root/zbdata directory to the/root/test/directory of the remote host 10.1.11.210
#scp-R/root/zbdata/[email protected]:/root/test
If you see that you need to enter the password for the remote host user name, you can copy it successfully
2. Copy the directory or file of the remote host to Local:
A. Copying files
#scp remote User name @ip address: file name 1 [local User name @ip address:] File name 2
Several parameters that may be useful:
-V is the same as-V in most Linux commands to show progress. Can be used to view connections, certifications, or configuration errors
-C Enable Compression option
-P Select the port. Note-P has been used by RCP
-4 forcibly use IPV4 address
-6 forcibly use IPV6 address
Example: Copy the A.txt file under the/root/zbdata/directory of the remote host 10.1.11.210 to the local/root/zbdata
#scp [Email protected]:/root/zbdata/a.txt/root/zbdata/
B. Copy Directory
#scp-R remote User name @ip address: directory name [local user name @ip address:] Directory name
Example: Copy the/root/test/directory of the remote host 10.1.11.210 to the local/root/zbdata directory
#scp-R [email protected]:/root/test//root/zbdata/
Note two points:
1. If the remote server firewall has special restrictions, the SCP will go to the special port, depending on what port, depending on the situation, the command format is as follows:
#scp-P 4588 [email protected]:/root/test/a.txt/root/zbdata/
2. Use SCP be aware that the user you are using has permission to read the appropriate files for the remote server.
Linux SCP command details and application examples