rsync認證失敗無法同步

最近有新主機要建置同步機制。同事把主機裝好,並將並將rsync的設定檔案都複製到相關主機上,請我做後續的同步機制建置。但是當我實際去執行rsync去同步程式時,卻出現以下錯誤…
註:我是採用daemon模式。XXXXXXX是設定檔的名稱
Password:
@ERROR: auth failed on module XXXXXXX
rsync error: error starting client-server protocol (code 5) at main.c(1506) [sender=3.0.7]
再度檢查所有的設定檔及設定的內容、以及確認我輸入的密碼都無誤,卻仍然有以上的錯誤

查看rsync的log(/var/log/rsync.log),看到以下的錯誤資訊
2015/12/28 11:55:38 [39349] secrets file must not be other-accessible (see strict modes option)
2015/12/28 11:55:38 [39349] auth failed on module XXXXXXX from xxx.test.com (1.1.1.1) for sync: ignoring secrets file

才想起來,daemon模式所使用的帳號設定檔 rsyncd.secrets,必須設定成不可以被呼叫服務起來以外的帳號存取。以我為例,我是使用root啟動rsync daemon。因此,不可以讓root以外的帳號有存取權限
strict modes
This parameter determines whether or not the permissions on the secrets file will be checked. If "strict modes" is true, then the secrets file must not be readable by any user ID other than the one that the rsync daemon is running under. If "strict modes" is false, the check is not performed. The default is true. This parameter was added to accommodate rsync running on the Windows operating system.
註:詳細說明請見rsyncd.conf

可能是他們複製rsync設定檔案時有更改到權限設定。因此,使用 chmod 600 rsyncd.secrets 移除其他的存取權限後,就可正常同步了。

留言