Scp全量远程拷贝(推送、拉取)

版权声明:©来自CSDN博客作者"Debug The Life"的原创作品,如需转载,请注明出处。 https://blog.csdn.net/zhaoxixc/article/details/82079388
  • 参数

-P:指定端口,默认22可不写(P大写)

-r:递归拷贝目录

-p:属性不变

-l:限制速度 (如 -l 1024 默认单位M)

源主机:192.168.10.158
源文件:/root/software/apache-tomcat-8.5.32.tar.gz

目的主机:192.168.10.178
目的位置:/tmp/
  • 推送实例

在源主机进行推送

[root@fudanwuxi ~]# cd /root/
[root@fudanwuxi ~]# ll software/
total 190660
-rw-r--r--. 1 root root   9584807 Aug 20 13:40 apache-tomcat-8.5.32.tar.gz
-rw-r--r--. 1 root root 185646832 Aug 20 13:33 jdk-8u181-linux-x64.tar.gz

[root@fudanwuxi ~]# scp -P22 -pr /root/software/apache-tomcat-8.5.32.tar.gz [email protected]:/tmp 
The authenticity of host '192.168.10.178 (192.168.10.178)' can't be established.
ECDSA key fingerprint is SHA256:plDF/rfSdZkeOwQLGhV7M9NlvcQR78+4n1zWFE/Kw8E.
ECDSA key fingerprint is MD5:c1:79:b6:7e:a3:bb:52:50:d4:47:59:46:8c:87:ad:ee.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.178' (ECDSA) to the list of known hosts.
root@192.168.10.178's password: 
apache-tomcat-8.5.32.tar.gz                                      100% 9360KB  17.8MB/s   00:00   

在目的主机的目的位置进行查看

[root@fudanwuxi002 /]# cd /tmp/
[root@fudanwuxi002 tmp]# ll | grep apache-tomcat-8.5.32.tar.gz 
-rw-r--r--. 1 root root 9584807 820 13:40 apache-tomcat-8.5.32.tar.gz
[root@fudanwuxi002 tmp]# pwd
/tmp
[root@fudanwuxi002 tmp]# ifconfig | grep 192.168.10
        inet 192.168.10.178  netmask 255.255.255.0  broadcast 192.168.10.255
  • 拉取实例

源主机将目的主机的/etc/yum.repos.d/内的文件拉取到本地的/root/Downloads/下

[root@fudanwuxi ~]# scp -P22 -pr root@192.168.10.178:/etc/yum.repos.d/ /root/Downloads/
[email protected]'s password: 
CentOS-CR.repo                                                   100% 1309    56.8KB/s   00:00    
CentOS-Debuginfo.repo                                            100%  649   373.7KB/s   00:00    
CentOS-Media.repo                                                100%  630   369.7KB/s   00:00    
CentOS-Sources.repo                                              100% 1331   628.1KB/s   00:00    
CentOS-Vault.repo                                                100% 3830   433.0KB/s   00:00    
CentOS-fasttrack.repo                                            100%  314   134.4KB/s   00:00    
CentOS-Base.repo.bak                                             100% 1664   187.6KB/s   00:00    
CentOS-Base.repo                                                 100% 1495   149.4KB/s   00:00    
[root@fudanwuxi ~]# ll /root/Downloads/
total 0
drwxr-xr-x. 2 root root 215 Aug  2 20:20 yum.repos.d

猜你喜欢

转载自blog.csdn.net/zhaoxixc/article/details/82079388