1. 修改配置文件
[root@host253 ~]# vim /etc/rsyncd.conf
uid = nobody gid = nobody use chroot = yes max connections = 4 pid file = /var/run/rsyncd.pid exclude = lost+found/ transfer logging = yes timeout = 900 ignore nonreadable = yes dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 //以上内容为系统默认自带选项,无需修改
auth users = lock //rsync虚拟用户,自定义 secrets file = /root/rsync.pass //rsync虚拟用户使用的密码文件路径 read only = false //是否为只读 fake super = yes //使rsync进程拥有root权限,可以复制文件 [ftp] //rsync模块的名称(自定义) path = /home/ftp //rsync模块的路径(自定义) comment = ftp export area //rsync模块的注释(自定义)
[backup] path = /backup comment = backup 192.168.1.253
2. 创建对应的模块路径,并修改所有者
mkdir /backup chown nobody.nobody /backup
3. 创建虚拟用户使用的密码文件,并设定权限为600
echo "lock:1" > /root/rsync.pass chmod 600 !$
4. 重启服务
systemctl restart rsyncd
注意: rsync使用的端口号为tcp:873,需要在防火墙开放对应端口 firewall-cmd --permanent --add-port=873/tcp firewall-cmd --reload