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

  • 参数

-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 root@192.168.10.178:/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/
root@192.168.10.178'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
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值