scp(传输数据无需密码) rsync(增量更新)

 

scp之间实现传输数据无需密码

1、scp命令格式

      1)传输文件

           scp 文件名 远程服务器IP:远程服务器路径

           scp 远程服务器IP:文件名 本地路径

      2)传输目录

           scp -r 目录名 远程服务器IP:远程服务器路径

           scp -r 远程服务器IP:目录名 本地路径

2、在主服务器执行ssh-keygen -t rsa,完成后会在/root/.ssh/目录生成id_rsa 、id_rsa.pub,把id_rsa 复制到备服务器/root/.ssh/目录。并更改名称为authorized_keys

[root@pg1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
14:18:7d:5d:2e:6c:b5:2a:2c:25:fe:2e:dc:cd:d7:83
root@pg1
3、rsync

将192.168.195.130 服务器下/test/目录的文件增量增加到本机/test目录

[root@pg1 test]# rsync -avlH 192.168.195.130:/test/ /test
receiving file list ... done
./
123a2dss.ssql
123a2s.sql
123as.sql

sent 92 bytes  received 250 bytes  36.00 bytes/sec
total size is 0  speedup is 0.00

你可能感兴趣的:(linux)