CentOS5 ssh單向授權與rsync網站內容同步化工作紀錄

=======ssh單向授權=================
# cd /root/.ssh/
# ssh-keygen -d
一路按enter到最後
ls後可以看到兩個檔案…id_dsa與id_dsa.pub 現在要把id_dsa.pub丟到192.168.0.1 並且更名為authorized_keys2
# scp id_dsa.pub 192.168.0.1:/root/.ssh/authorized_keys2
然後看看應該可以執行ssh 192.168.0.1 看看能否登入而不需要輸入密碼…

=======rsync網站內容同步化==============
預設有安裝rsync 但是是關閉的且透過xinet控管

修改設定檔案開啟rsync
vim /etc/xinetd.d/rsync
裡面的disable=yes 設成no

service xinetd reload 完成

chkconfig –list 看一下

=================================
自行安裝版本
yum -y install xinetd rsync
chkconfig –level 345 xinetd on
vi /etc/xinetd.d/rsync
vi /etc/rsync.secrets
vi /etc/rsync.conf
chown root.root /etc/rsync.*
chmod 600 /etc/rsync.*
service xinetd restart
================================

================================
防火牆部分 (預設是873port)
# telnet 127.0.0.1 873
Trying 127.0.0.1…
telnet: connect to address 127.0.0.1: Connection refused
# iptables -A INPUT -s 192.168.0.0/255.255.255.0 -p tcp -m tcp –dport 873 -j ACCEPT
# iptables -A INPUT -p tcp -m tcp –dport 873 -j DROP
================================

然後再來進行同步的細節了
就crontab,
*/5 * * * * rsync -av -e ssh [email protected]:/var/www/html/ /var/www/html/
類似這樣
以下略