系统环境是 ubuntu 11.10 serversudo cp /usr/share/doc/rsync/exmple/rsyncd.conf /etc/需要的修改$sudo vim /etc/default/rsyncRSYNC_ENABLE=true我的配置文件内容:# sample rsyncd.conf configuration file# GLOBAL OPTIONS#motd file=/etc/motdlog file=/var/log/rsyncd# for pid file, do not use /var/run/rsync.pid if# you are going to run rsync out of the init.d script.pid file=/var/run/rsyncd.pid#syslog facility=daemon#socket options=# MODULE OPTIONS[shops] comment = public archive path = /var/cdn/shops use chroot = no"test1" 119L, 3550C 1,0-1 Top path = /var/cdn/shops use chroot = no max connections=6 lock file = /var/lock/rsyncd# the default for read only is yes... read only = yes list = yes uid = craxyz gid = craxyz# exclude =# exclude from =# include =# include from = auth users = craxyz secrets file = /etc/rsyncd.pass strict modes = yes# hosts allow =# hosts deny = ignore errors = no ignore nonreadable = yes transfer logging = no# log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes. timeout = 600 refuse options = checksum dry-run dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz创建一个密码文件(就是配置文件中指定的那个哦, secrets file = /etc/rsyncd.pass,不是默认的名字了。)$sudo vim /etc/rsyncd.passcraxyz:******$sudo chmod 0600 /etc/rsyncd.pass启动rsyncsudo /etc/init.d/rsync startclient$rsync -vzrtogu --progress craxyz@192.168.0.53::shops(服务端定义的字段名) . (绝对路径和相对路径均可,此处是已经在目标目录)输入密码~~出现下面信息--成功sent 2517 bytes received 2161202 bytes 865487.60 bytes/sectotal size is 2169700 speedup is 1.00crontab执行创建需要自动读取的密码文件(其实就是免去我们需要输入的密码)$sudo vim /home/sysadmin/test/rsyncd.pass输入******,保存,(******是服务段认证用户的密码)注意:sudo chmod 600 /home/sysadmin/test/rsyncd.pass然后我们打开crontab,加入以下任务$crontab -e* */1 * * * rsync -vzrogu --password-file=/home/sysadmin/test/rsyncd.pass craxyz@192.168.0.53::shops /var/cdn/shops遇到的报错信息报错信息如下:@ERROR: auth failed on module shopsrsync: connection unexpectedly closed (0 bytes received so far) [receiver]rsync error: error in rsync protocol data stream (code 12) at io.c(359)查看rsync服务器端的日志文件有如下提示 secrets file must not be other-accessible (see strict modes option) continuing without secrets file服务器端/etc/rsyncd.pass的密码文件权限不对,应为600,将该文件的权限更改为600后同步正常。 (要重启服务生效)总结:服务器端的rsync的密码文件格式为username:password,权限为600客户端密码文件格式为password,需同服务器端,权限为600,否则同 步会报错还有一个问题就是密码文件中的用户名的问题.如果遇到其他的错误信息应该要检查下用户名和密码的正确性.