首页 » 操作系统 » Linux » Linux下用root用户验证进行Rsync同步

Linux下用root用户验证进行Rsync同步

 

在使用rsync同步时,如果用nobody,那么同步目录权限必须是755,但是在使用中,有些目录下文件的o权限都是0.而且不断的产生新的文件,所属用户和组都是root,权限也都是740,这种情况,同步时候出现下面的情况:

rsync: link_stat "." (in roke) failed: Permission denied (13)

权限不足,不可能用chmod来每时每刻的改变新产生文件的权限,所以就需要有权限的用户(root)来通过rsync同步文件。

服务器端配置:

[root@localhost/]# cat /etc/rsyncd.conf
use chroot = false
strict modes = false
read only = yes
list = no
hosts allow = *
max connections = 10
lock file = /var/run/rsyncd.lock
motd file = /var/run/rsyncd.motd
log file = /var/run/rsyncd.log
transfer logging = yes
uid = nobody
gid = nobody
#auth users= root
#secrets file = /etc/rsyncd.pas
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[test]
uid = 0
gid = 0
path = /heminjie
read only = yes
transfer logging = yes
ignore errors
auth users= root
secrets file = /etc/rsyncd.pas

新建rsyncd.pas文件(里面是root和root的密码):
vi /etc/rsyncd.pas输入:root:root密码
root:da2010##
 
保存完毕,chmod 600 /etc/rsyncd.pas 更改权限
 
客户端配置:
vi /etc/rsyncd.pas输入root的密码
da2010##
 
保存完毕,chmod 600 /etc/rsyncd.pas 更改权限
 
rsync用root用户验证的同步命令:

rsync -vzrtopg --delete --progress root@192.168.0.51::test /heminjie1 --password-file=/etc/rsyncd.pas

原文链接:Linux下用root用户验证进行Rsync同步,转载请注明来源!

1