1.編輯rsync配置文件
vim /etc/rsyncd.conf
uid = nobodygid = nobodyuse chroot = nomax connections = 10pid file = /var/run/rsyncd.pidlock file = /var/run/rsyncd.locklog file = /var/log/rsyncd.logmotd file = /etc/rsyncd.motdhosts allow = 127.0.0.1 192.168.0.0/255.255.255.0auth users = rsyncusersecrets file = /etc/rsyncd.secrets[rsync]path = /rsynccomment = ServerHomeread only = truelist =false
uid、gid必須是內建用戶,這裏用nobody帳號作爲最小權限。
auth users是虛擬用戶,有多個的話用逗號隔開。
2.建立rsync目錄
mkdir /rsync
chown nobody. /rsync
3.定義服務器信息文件
echo "rsyncserver for test" > /etc/rsyncd.motd
4.定義密碼文件
echo "rsyncuser:test" > /etc/rsyncd.secrets
test是密碼,不支持加密
5.設置目錄權限
chmod 600 /etc/rsyncd.conf
chmod 600 /etc/rsyncd.motd
chmod 600 /etc/rsyncd.secrets
6.重啓服務
service xinetd restart
客戶端測試
建立密碼文件
echo "test" > /root/secrets
chmod 600 /root/secrets
測試
rsync -Rav --delete --password-file=/root/secrets [email protected]::rsync /tmp