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

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

我遇到的所有主题都涉及rsyncssh使用rsync具有受限访问权限的用户。

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

/etc/rsyncd.conf:

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

[backupdir]
    path = /backupdir

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

backup:backuppassword
root:rootpassword

执行 rsync 的 bash 脚本:

export RSYNC_PASSWORD=rootpassword

rsync -a --verbose --delete rsync://root@myserver/backupdir mydestination

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

答案1

从主页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. [...]

即,您为 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".

例如:

uid = johndoe
gid = johndoe

相关内容