rsync 由 xinetd 管理,兩個都要裝:
yum install rsync xinetd
chkconfig rsync on
service xinetd restart
setenforce 0
找到包含 server_args 的那一行,改成:
server_args = --daemon --config=/etc/rsyncd/rsyncd.conf
cd /etc
mkdir rsyncd
cd rsyncd
touch rsyncd.conf rsyncd.passwd
chmod 600 rsyncd.passwd
vi rsyncd.conf
uid = root
gid = root
use chroot = no
read only = yes
hosts allow = 124.3.1.3/255.255.255.0 11.16.52.249/255.255.255.0
hosts deny = *
max connections = 5
pid file = /var/run/rsyncd.pid
secrets file = /etc/rsyncd/rsyncd.passwd
transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
[module]
path = /var/www/html/test
list = yes
ignore errors
auth users = username
comment = test
# exclude = cache/
hosts allow 建議只放行可信的來源網段,避免服務暴露在不相關的網路中。
vi /etc/rsyncd/rsyncd.passwd
格式為一行一組帳號:
username:password
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT
rsync -avz --progress username@11.16.52.249::module ./test
依提示輸入上一步設定的密碼即可。
遇到問題時先確認 SELinux 狀態與埠是否監聽:
getenforce
netstat -an | grep 873
https://xxxxxx/Linuxjc/1184804.html TechArticle