一、安装rsync
#tar zxvf rsync-2.6.3.tar.gz
#cd rsync-2.6.3
#./configure
#make
#make install----------------------------服务器端-------------------------------
#vi /etc/rsyncd.conf
运行:
#/usr/local/bin/rsync --daemon
----------------------------请求端-------------------------------
vi /etc/rsync.pass
设置用户密码
chmod 600 /etc/rsync.pass
/usr/bin/rsync -vzrtopg --delete --progress tiansi@202.100.250.69::www /home/web/ --password-file=/etc/rsync.pass
============================SSH结合rsync===============================
服务端(可不安装rsync):
SSH2登录:ssh-keygen -X -f webback-rsync-key.pub >> authorized_keys2
客户端:
可用root帐号操作
#ssh-keygen -t dsa -b 2048 -f /home/cron/webback-rsync-key #注意这里不需要输入passphrase
#webback-rsync-key.pub上传到服务器端。
#vi rsync.sh
#chmod +x rsync.sh
0,30 * * * * /home/cron/rsync.sh
#tar zxvf rsync-2.6.3.tar.gz
#cd rsync-2.6.3
#./configure
#make
#make install----------------------------服务器端-------------------------------
#vi /etc/rsyncd.conf
引用
uid = ftp
gid = ftpusers
use chroot = no
max connections = 4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[www]
path = /home/www/
comment = Welcome to rsyncd host
ignore errors
read only = true
list = false
auth users = tiansi
hosts allow = 220.174.234.56
secrets file = /etc/rsyncd.secrets
gid = ftpusers
use chroot = no
max connections = 4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[www]
path = /home/www/
comment = Welcome to rsyncd host
ignore errors
read only = true
list = false
auth users = tiansi
hosts allow = 220.174.234.56
secrets file = /etc/rsyncd.secrets
运行:
#/usr/local/bin/rsync --daemon
----------------------------请求端-------------------------------
vi /etc/rsync.pass
设置用户密码
chmod 600 /etc/rsync.pass
/usr/bin/rsync -vzrtopg --delete --progress tiansi@202.100.250.69::www /home/web/ --password-file=/etc/rsync.pass
============================SSH结合rsync===============================
服务端(可不安装rsync):
引用
useradd back
su back
cd /home/back
if [ ! -d .ssh ]; then mkdir .ssh ; chmod 700 .ssh ; fi
mv webback-rsync-key.pub .ssh/
cd .ssh/
if [ ! -f authorized_keys ]; then touch authorized_keys ; chmod 600 authorized_keys ; fi
SSH1登录:cat webback-rsync-key.pub >> known_hosts
if [ ! -f authorized_keys2 ]; then touch authorized_keys2 ; chmod 600 authorized_keys2 ; fi
su back
cd /home/back
if [ ! -d .ssh ]; then mkdir .ssh ; chmod 700 .ssh ; fi
mv webback-rsync-key.pub .ssh/
cd .ssh/
if [ ! -f authorized_keys ]; then touch authorized_keys ; chmod 600 authorized_keys ; fi
SSH1登录:cat webback-rsync-key.pub >> known_hosts
if [ ! -f authorized_keys2 ]; then touch authorized_keys2 ; chmod 600 authorized_keys2 ; fi
SSH2登录:ssh-keygen -X -f webback-rsync-key.pub >> authorized_keys2
客户端:
可用root帐号操作
#ssh-keygen -t dsa -b 2048 -f /home/cron/webback-rsync-key #注意这里不需要输入passphrase
#webback-rsync-key.pub上传到服务器端。
#vi rsync.sh
#chmod +x rsync.sh
0,30 * * * * /home/cron/rsync.sh