无密码通过ssh执行rsync

1.使用ssh-keygen生成密匙

$ ssh-keygen Enter passphrase (empty for no passphrase):

Enter same passphrase again:

2.使用ssh-copy-id将公匙拷贝至远程主机

ssh-copy-id -i ~/.ssh/id_rsa.pub IP(192.168.0.1)

3.通过ssh来执行rsync

ssh 192.168.0.1
rsync -avzut /var/www/ root@192.168.0.1:/home/wwww
点赞