Rsync hardening technology (when firewall is enabled by manually modifying the port) and synchronizing only the desired server through the script
Client: 192.168.0.22, 192.168.0.20
Server: 192.168.0.21 (source) is used to synchronize with other servers.
I wrote earlier
Http://chenhao6.blog.51cto.com/6228054/1298375inotify+rsync+mutt+msmtp enables automatic update of linux files or directories and sends emails to administrators
However, some functions cannot be implemented. what do you do if you want to update only a few of them.
The solution is provided here.
First, the client configuration script 192.168.0.22
| 1234567891011121314151617181920212223242526 |
#!/bin/bash# Client 192.168.0.22 (multiple)yum -y installrsynccat>> /etc/rsyncd.conf << EOFuid = rootgid = rootuse chroot = nomax connections = 100timeout = 600pid file=/var/run/rsyucd.pidlock file= /var/run/rsyncd.locklog file= /var/log/rsyncd.log[www]path = /home/wwwignore errorsreadonly = nolist = nohosts allow = 192.168.0.21/255.255.255.0auth users= www1secrets file= /etc/www1.pwdEOFecho"www1:123">> /etc/www1.pwdchmod600 /etc/www1.pwdecho"Welcome to use the rsync services">> /var/rsyncd.motd/usr/bin/rsync--daemonecho"/usr/bin/rsync --daemon">> /etc/rc.local |
192.168.0.20 client configuration script
| 12345678910111213141516171819202122232425262728 |
#!/bin/bash# Client 192.168.0.20# What are the meanings of these configuration files? previous articles have written specific articles. please refer to the connection above.yum -y installrsynccat>> /etc/rsyncd.conf << EOFuid = rootgid = rootuse chroot = nomax connections = 100timeout = 600pid file=/var/run/rsyucd.pidlock file= /var/run/rsyncd.locklog file= /var/log/rsyncd.log[www]path = /home/wwwignore errorsreadonly = nolist = nohosts allow = 192.168.0.21/255.255.255.0# Comment out the comment here. if anyone is allowed to access multiple hosts, add a space of 192.168.0.22/255.255.255.0.auth users= www1secrets file= /etc/www1.pwdEOFecho"www1:123">> /etc/www1.pwdchmod600 /etc/www1.pwdecho"Welcome to use the rsync services">> /var/rsyncd.motd/usr/bin/rsync--daemonecho"/usr/bin/rsync --daemon">> /etc/rc.local |
The following key moments are coming.
Both servers run
| 12 |
/usr/bin/rsync-- Address = 192.168.0.22 -- port = 998 -- daemon his own port/usr/bin/rsync-- Address = 192.168.0.21 -- port = 998 -- daemon updates the source port |