以 root 用户身份使用 Rsync 的权限被拒绝

Ash*_*Ash 5 linux bash rsync permissions

所有的主题,我遇到参与rsyncsshrsync使用限制访问的用户。

我以 root 身份收到权限被拒绝 (13) 错误。这是我的配置文件:

/etc/rsyncd.conf:

auth users = backup, root
secrets file = /etc/rsyncd.secrets

[backupdir]
    path = /backupdir
Run Code Online (Sandbox Code Playgroud)

/etc/rsyncd.secrets(文件模式600,所有者根,组根):

backup:backuppassword
root:rootpassword
Run Code Online (Sandbox Code Playgroud)

执行 rsync 的 bash 脚本:

export RSYNC_PASSWORD=rootpassword

rsync -a --verbose --delete rsync://root@myserver/backupdir mydestination
Run Code Online (Sandbox Code Playgroud)

上面的 bash 脚本mydestination驻留在 Win XP 机器上,myserver是一个 Debian 服务器。

n.s*_*.st 7

从主页为rsyncd.conf

auth users
       This parameter specifies a comma and space-separated list of usernames
       that will be allowed to connect to this module. The usernames do not need
       to exist on the local system. [...]
Run Code Online (Sandbox Code Playgroud)

即,您为 rsync 守护程序选择的用户名未链接到系统的同名用户。

但是,您可以设置 rsync 守护程序在访问文件时应使用的用户 ID 和组 ID(至少在您以 root 权限启动守护程序时):

uid    This  parameter  specifies  the user name or user ID that file transfers to
       and from that module should take place as when the daemon was run as root.
       In combination with the "gid" parameter this determines what file permissions
       are available. The default is uid -2, which is normally the user "nobody".

gid    This parameter specifies the group name or group ID that file transfers to
       and from that module should take place as when the daemon  was  run  as  root.
       This complements the "uid" parameter. The default is gid -2, which is normally
       the group "nobody".
Run Code Online (Sandbox Code Playgroud)

例如:

uid = johndoe
gid = johndoe
Run Code Online (Sandbox Code Playgroud)