Ubuntu VPS上配置rsync服務器
rsync是Linux下常用的同步軟件,本文介紹在Ubuntu VPS上怎樣安裝配置rsync服務器。
安裝rsync
執行如下命令安裝:
apt-get install -y rsync
然后可以用如下命令看看安裝了哪些文件:
dpkg -L rsync
配置rsync
修改配置文件/etc/default/rsync中的相應內容為:
RSYNC_ENABLE=true
增加配置文件/etc/rsyncd.conf,內容為:
port = 873
uid = root
gid = root
use chroot = yes
read only = yes
hosts allow=204.74.0.0/255.255.0.0
hosts deny=*
max connections = 5
log file = /var/log/rsyncd.log
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
[public]
path = /home/pics/www
list=yes
ignore errors
auth users = pics
secrets file = /etc/rsyncd.secrets
comment = pics www
創建文件 /etc/rsyncd.secrets 內容是用戶名和密碼,比如:
pics:mypassword
然后執行如下命令:
chmod 700 /etc/rsyncd.secrets
這樣就配置好了,可以運行如下命令啟動rsync服務端了:
/etc/init.d/rsync restart
rsync客戶端
在客戶端就可以用rsync命令了,比如:
rsync rsync://pics@216.18.195.23/public
rsync --password-file=/etc/rsync.password rsync://pics@216.18.195.23/public /home/pics/www --recursive --times --links --hard-links --delete -av