Chinaunix首页 | 论坛 | 博客
  • 博客访问: 56724
  • 博文数量: 12
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 115
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-11 09:37
文章分类

全部博文(12)

文章存档

2019年(10)

2013年(2)

我的朋友

分类: 网络与安全

2019-03-04 13:23:40

rsync推送目录文件权限设置

 

需求:本地(windows7)使用cwRsync往服务器(linux)上推送文件。

 

问题:由于本地是windows机器,无法和linux权限保持一致,本地cwRsync推送文件到服务器上后。文件权限变成了700

解决办法:通过rsync帮助文档可以找到,rsync服务端可以设置相应参数,来解决权限不一致问题。

incoming chmod

This parameter allows you to specify a set of comma-separated chmod strings that will affect the permissions of all incoming files (files that are being received by the daemon). These changes happen after all other permission calculations, and this will even override destination-default and/or existing permissions when the client does not specify --perms. See the description of the --chmod rsync option and the chmod(1) manpage for information on the format of this string.

 

在服务端修改rsyncd.conf,因为我的服务端文件权限都是www,修改uidgidwww,并增加incoming chmod参数

uid = www

gid = www

use chroot = no

hosts allow=*

max connections = 1

[data]

auth users = ad

secrets file = /etc/rsync.secrets

incoming chmod = Du=r,Dgo=r,Fu=r,Fgo=r

path = /data/

read only = false

上面是给出的一个服务端的示例,此时本地推送到服务端的文件和目录权限就变成了444

 

incoming chmod = Du=r,Dgo=r,Fu=r,Fgo=r表示设置服务器收到的文件权限

 

其中D表示目录,F表示文件

 

Du=r,Dgo=r表示目录权限是444

Fu=r,Fgo=r表示文件权限是444

incoming chmod另一种写法如下

incoming chmod = D444,F444

 

附:本地win7推送到服务器bat脚本如下

cd c:\cwRsync

rsync -azvP --password-file=/cygdrive/c/cwRsync/mima.txt /cygdrive/e/123.rar ad@10.10.10.10::data

pause

阅读(2796) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~