<>1. background

As a back-end development or operation and maintenance engineer , Server is a technology we must firmly grasp . In this section, we mainly explore ContOS7 The usage and example of remote copy file under .

Speaking of CentOS Copy in , What we use most often is cp Yes , The format is cp Source directory or file Target directory or file .

Examples , We will use the /home/test.txt copy to /tmp lower : cp /home/test.txt /tmp.

of course , This is not the protagonist we're going to talk about today , Our main character today is scp Remote copy command , This is quite convenient to copy between servers in a LAN .

<>2. Examples

grammar
scp [ Optional parameters ] [[user@]host1:]file1 [...] [[user@]host2:]file2 perhaps scp [ Optional parameters ]
file_source file_target
Examples

Copy files from local to remote server
scp local_file remote_username@remote_ip:remote_folder perhaps scp local_file
remote_username@remote_ip:remote_file perhaps scp local_file remote_ip:remote_folder
perhaps scp local_file remote_ip:remote_file
* The first 1,2 The user name is specified , After the command is executed, you need to enter the password again
* The first 3,4 There are no user names specified , The user name and password are required after the command is executed
* The first 1 Remote only directories specified , The file name remains unchanged
* The first 2 File name specified
* The first 3 Remote only directories specified , The file name remains unchanged
* The first 4 File name specified
example

Local 192.168.200.50 and 192.168.200.51 Two servers , I need to put 50 Server /home/test.txt File copy to 51 Of /tmp
Under the table of contents .
scp /home/test.txt [email protected]:/tmp/
192.168.200.50 The execution order is as follows

192.168.200.51 Execute the view command as follows

Technology