CentOS下配置rsyncd服务器

创建rsyncd服务的配置文件
touch  /etc/rsyncd .conf                                         // 主配置文件
touch  /etc/rsyncd .secrets                                      // 用户名密码文件
chmod  600  /etc/rsyncd .secrets                                  //rsyncd 服务的密码文件权限必须是600
编辑主配置文件 rsyncd.conf
uid = root
gid = root
use chroot =  yes                                                         //chroot yes 时必须使用root权限,且不能备份path路径外的链接文件
read  only = no                                                           // 只读
write only = no                                                          // 只写
max connections = 5                                                      // 客户端最大连接数
log  file  /var/log/rsyncd .log                                           // 指定 rsync 发送消息日志文件
log  format  = %t %a %m %f %b                                              // 日志文件格式
timeout = 300                                                            // 连接超时时间
 
 
[ test ]                                                                  //自定义模块名称
path= /soft                                                               // 需要同步的目录
list= yes                                                                 // 是否允许列出模块里的内容
ignore errors
auth  users  = userID                                                        // 模块验证用户名称
secrets  file = /etc/rsyncd/rsyncd .secrets                                  // 模块验证密码文件 可放在全局配置里
设定rsyncd为独立的守护进程并配置rsyncd.secrets
vim  /etc/rsyncd .secrets                                         // 配置密码文件
echo  test :IP >>  /etc/rsyncd .secrets
/usr/bin/rsync  --daemon
echo  "rsync –daemon"  >>  /etc/rc . local                                 // 添加到自启动文件

为了保证开机时自动启动,需要手动加上面的命令(/usr/bin/rsync --daemon --config=/etc/rsyncd.conf)加入 /etc/rc.local 文件中
如果服务器开启了防火墙,必须保证端口能穿过防火墙

vim  /etc/sysconfig/iptables
开放873端口
iptables -A INPUT -p tcp -m state --state NEW  -m tcp --dport 873 -j ACCEPT
客户端执行rsync命令测试配置是否成功

IP限制方式:

rsyncd.conf配置

uid = root
gid = root
use chroot = no
read  only = no
write only = no
max connections = 5
log  file  /var/log/rsync .log
log  format  = %t %a %m %f %b
syslog facility = local3
timeout = 300
[ test ]
hosts allow = 允许连接的IP
hosts deny = *
path =  /soft
list= yes
ignore errors

以daemon方式启动

/usr/bin/rsync  --daemon --config= /etc/rsyncd .conf

客户端执行rsync命令测试配置是否成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值