Ubuntu Server 18.04 配置 rsync(xinetd)
作者:互联网
【服务端配置】
系统版本
# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.2 LTS Release: 18.04 Codename: bionic
sudo apt install rsync xinetd
在 /etc/default/rsync 文件内修改或添加
RSYNC_ENABLE=inetd
创建 /etc/xinetd.d/rsync 文件,添加如下内容:
service rsync{ disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += 0 # user ID }
创建 /etc/rsyncd.conf 文件,添加如下内容:
max connections = 5 log file = /var/log/rsync.log lock file = /var/lock/rsyncd.lock timeout = 300 charset = UTF-8 # 用于避免中文乱码 [share] # 模块名 comment = Public Share # path为需要同步的文件夹路径 path = /var/test read only = no list = yes uid = root gid = root # 必须和 rsyncd.secrets中的用户名对应 auth users = walker secrets file = /etc/rsyncd.secrets
创建 /etc/rsyncd.secrets 文件,添加如下内容:
# 配置用户名和密码,密码可以任意设置 walker:test
修改 rsyncd.secrets 文件权限
sudo chmod 600 /etc/rsyncd.secrets
启动/重启 xinetd
sudo /etc/init.d/xinetd restart
如果端口未被监听,可尝试重启
# netstat -anop | grep 873 tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 929/rsync off (0.00/0/0) tcp6 0 0 :::873 :::* LISTEN 929/rsync off (0.00/0/0)
【客户端测试】
系统版本(Windows 10 x64 1803)
winver
客户端软件版本
cwRsyncServer 4.0.5.0
将服务端文件同步至本地
rsync -cvazu --progress walker@192.168.136.131::share ./test # --iconv=locale_charset,remote_charset 用于避免中文乱码 rsync -cvazu --progress --iconv=UTF-8,GB18030 walker@192.168.136.131::share ./test
若报以下错误,查看服务器端口是否开放(检查防火墙,重启服务器...)
rsync: failed to connect to 218.107.243.2: No route to host (113) rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
【名词解释】
xinetd: eXtended InterNET services daemon
*** walker ***
标签:rsync,18.04,secrets,Server,etc,xinetd,rsyncd,walker 来源: https://blog.51cto.com/walkerqt/2373028