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 = GB18030    # 用於避免中文亂碼

[share] # 模塊名
comment = Public Share
# path爲需要同步的文件夾路徑
path = /var/test
hosts allow = 192.168.0.0/16
hosts deny = *
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 [email protected]::share ./test
# --iconv=locale_charset,remote_charset 用於避免中文亂碼
rsync -cvazu --progress --iconv=UTF-8,GB18030 [email protected]::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 *** 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章