Linux remote copy scp

Linux's scp command can copy files between two servers. My test environment is Centos6.4.

Basic command format

scp copy target file remote user @ remote host address: remote directory

1. Copy from the local machine to the target remote host

# scp php- 7.2. 4.tar.gz root @ 192.168. 9.142: / usr / local / src / // This is copied from the current host to the LAN host directory / usr / local / src of IP bit 142
The authenticity of host ' 192.168.9.142 (192.168.9.142) ' can ' t be established. RSA key fingerprint is 11: b6: be: 81: a0: be: b7: 14: b4: 2d: d6: 99 : de: 8d: 7c: f1. Are you sure you want to continue connecting (yes / no)? Yes // Enter a prompt will pop up, then enter yes
root @ 192.168. 9.142 ' s password: // Enter the password

After the execution is complete, go to the corresponding directory of the target remote host to view, the file is present, indicating success

Second, copy from the remote host to the machine

# scp root @ 192.168. 9.142: /usr/local/src/redis.tar.gz / usr / local / src /   // Here is the copy file from the target host 142 to the local / usr / local / src
root @ 192.168. 9.142 ' s password: // Enter the password of the remote host and press Enter
redis.tar.gz                                            100% 1696KB   1.7MB/s   00:00 

Supplement, copy multiple files or directories at once

# scp root @ 192.168. 9.142: / usr / local / src / cp_dir / * .php / usr / local / src / // Copy multiple files
# scp -r root @ 192.168. 9.142: / usr / local / src / cp_dir / / usr / local / src / // copy directory

Guess you like

Origin www.cnblogs.com/qfdy123/p/12732592.html