Installing rsync under LINUX

Source: Internet
Author: User
Tags auth rsync

First, server-side configuration:
1, install xinetd, and modify the rsync related configuration
# yum-y Install xinetd
# Vi/etc/xinetd.d/rsync
The following code:
Service rsync
{
Disable = yes
Socket_type = Stream
wait = no
user = root
Server =/usr/bin/rsync
Server_args =--daemon
Log_on_failure + = USERID
}
Change Disable = yes to disable = no
Then restart XINETD
#/etc/init.d/xinetd Restart
[
Note: If a firewall is installed on the server, you need to open the port, the default port is 873
# 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
]

2. Write rsync.conf configuration file
# vi/etc/rsyncd.conf
The contents are as follows:
port=873
UID = nobody
GID = Nobody
User Chroot = No
Max connections = 200
Timeout = 600
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsyncd.lock
Log file =/var/log/rsyncd.log

[WWW]
Path =/home/www
Ignore errors
Read Only = no
List = no
Hosts allow = 192.168.1.0/255.255.255.0 setting allows access to the IP can be * (All)
Auth users = root
Secrets file =/etc/rsyncd.secrets

Comments:
Port #开放端口
UID = Nobody #进行备份的用户UID, nobody for any user
GID = Nobody #进行备份的组GID, nobody for any group
Use chroot = no #如果 the "use Chroot" is specified as true, then rsync chroot to the directory specified by the path parameter before transferring the file. The reason for this is to implement additional security, but the disadvantage is that you need root permissions, and you cannot back up the directory files that point to external symbolic connections. By default, the Chroot value is true. But this is generally not necessary, so I choose No or false
List = no #不允许列清单
Max connections = #最大连接数
Timeout = #覆盖客户指定的IP超时时间, which means that the rsync server does not wait forever for a crashed client.
Pidfile =/var/run/rsyncd.pid #pid文件的存放位置
Lock file =/var/run/rsync.lock #锁文件的存放位置
Log file =/var/log/rsyncd.log #日志文件的存放位置

[Backup] #这里是认证模块名, like samba syntax, is a name that is published externally
Path =/home/www #这里是参与同步的目录
Ignore Errors #可以忽略一些无关的IO错误
Read Only = no #允许可读可写
List = no #不允许列清单
Hosts allow = 192.168.1.0/255.255.255.0 #这里跟samba的语法是一样的, allowing only 192.168.1.0/24 network segments to be synchronized, rejecting all other IPs
Auth users = admin #认证的用户名
Secrets file =/etc/rsyncd.secrets #密码文件存放地址

Note: The configuration file for this place, although the explanation is very clear, but some friends will always be here to make mistakes, here I mention the highlights easy wrong point:
[Backup] is the authentication module name and path =/var/www is the directory participating in the synchronization
Here's path everyone to remember, here do not casually set up directly to finish, you know here is the authentication module, later from the client backup data will be stored here.

3. Write User password file
# vi/etc/rsyncd.secrets
root:1234789 #用户名: Password

4. Give read-only permission
# chown Root:root/etc/rsyncd.secrets
# chmod 600/etc/rsyncd.secrets

-rw-------(+)-- only the master has read and write permissions.

-rw-r--r--(644)-- only the master has read and write permission, and the group user and other users have only the reading permission.

-rwx------()-- only the owner has read, write, and execute permissions.

-rwxr-xr-x (755)-- the owner has read, write, execute permissions, but the group users and other users only read, execute permissions.

-rwx--x--x (711)-- the owner has read, write, execute permissions, but the group user and other users only execute permissions.

-rw-rw-rw-(666)-- All users have file read and write permissions. This approach is undesirable.

-rwxrwxrwx (777)-- All users have read, write, and execute permissions. More undesirable approach.

Here are two general settings for the directory:

drwx------()- only the owner can read and write in the directory.

drwxr-xr-x (755)- All users can read the directory, but only the owner can change the contents of the directory

  suid The representative numbers are 4 , such as 4755 The result is -rwsr-xr-x

  Sgid The representative numbers are 2 , such as 6755 The result is -rwsr-sr-x

  Sticky bits represent numbers are 1 , such as 7755 The result is -rwsr-sr-t



5. Create a directory and modify the owner
# mkdir/home/www/
# Chown-r Nobody:nobody/home/www

6. Start the service
# rsync--daemon

7. Join the boot start
# echo "Rsync--daemon" >>/etc/rc.local

Second, the Linux client synchronizes
1, the client default seems to have been installed rsync, no words installed:
# yum-y Install rsync

2. Create a password file
# VI/ETC/RSYNCD.PASSWD
The contents of the file are as follows (contains only the password section):
123456789

3. Perform asynchronous synchronous operation:
#/usr/bin/rsync-avz--progress--password-file=/etc/rsyncd.passwd[email protected]:: www/home/www

Installing rsync under LINUX

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.