簡單設定rsync服務 有時候需要給其它部門提供遊戲或者網站某些日誌,這時候可以給他們伺服器帳號自己ssh擷取,但為安全方面考慮,還是用rsync配置模組為好,這樣除了檔案傳輸,不然有其它安全方面的問題。 大多linux系統都內建rsync,配置如下: /etc/rsyncd.conf uid = rootgid = rootstrict modes = yesmax connections = 3600use chroot = nolog file = /var/log/rsyncd.log #定義一些rsync檔案的目錄pid file = /var/run/rsyncd.pidlock file = /var/run/rsyncd.lock [datalog] #模組名path=/home/datalog #需同步的目錄ignore errors #忽略一些錯誤read only = yes #只有讀取許可權auth users = datacenter #是否需要認證使用者,不填以下兩行,只預設匿名secrets file = /etc/rsyncd.pass 密碼檔案的格式為user:pass,如cat /etc/rsyncd.pass datalog:datalog1234 注意,密碼檔案 /etc/rsyncd.pass許可權一定要設定為600許可權(chown root:root /etc/rsyncd.pass && chmod 600 /etc/rsyncd.pass ) 設定好之後,開啟rsync服務(rsync服務預設用873連接埠,注意開放防火牆) /usr/bin/rsync --daemon 此時在其它伺服器可以遠程通過rsync用戶端同步剛剛設定好的那個模組內容。 rsync -artuz -R --port=873 datalog@192.168.1.1::datalog ./ 按提示輸入密碼。 或者可以在用戶端也弄個密碼檔案, cat /etc/rsync.passdatalog1234 注意許可權也只能為600,然後執行命令直接同步處理檔案。 rsync -artuz -R --password-file=/etc/rsync.pass --port=873 datalog@113.107.161.10::datalog ./