proftpd复杂权限的设置

简介:
一、测试平台
Debian 4.0r3
Proftpd 1.3.1 (WITH SSL)

二、原理简介
1、 继承性
    子目录会继承其父目录的属性。
2、 优先级
    优先级由大到小的顺序:
    原始FTP命令(LIST  DELE等)  >  命令组(DIRS  READ  WRITE)  >  ALL命令组
3、 访问控制的应用顺序
    不论出现顺序如何,先应用拒绝(Deny),后应用允许(Allow)
4、系统权限
    Linux系统权限仍然起作用。如果设置了目录test的<Limit>允许写,但是该用户对test目录只有
    读权限,这是该用户就不能向test目录写入。


<Directory  /ftproot/test>      ----------------- 1、继承性
     <Limit DIRS>        ------------------------- 2、优先级
          AllowUser  u1          -------------------- 3、访问控制的应用顺序
          DenyAll
     </Limit>
</Directory>

    一点解释:根据参考1所述,访问控制的顺序应该是与其出现顺序有关,但是在我的测试中发现出现顺序没有什么影响。也就是说,像上面的访问控制,AllowUser u1和DenyAll哪个在前面都一样。
 
三、实例
1、简介
假设proftpd服务器上有5个用户:
        manager, manA1, manA2, manB1, manB2
和2个组:
        groupA, groupB
manA1和manA2属于groupA组,manB1和manB2属于groupB组。
并且有如下目录结构:
    /根目录 
    │ 
    ├ftproot/       
    │       ├manager/
    │       │
    │       ├groupA/
    │       │      ├A1/
    │       │      ├A2/
    │       │      └.../
    │       │
    │       ├groupB/
    │              ├B1/
    │              ├B2/
    │              └.../
    │
    └.../
现在要实现的权限:
1、用户manager可以读写manager、groupA、groupB目录及它们的的子目录。
2、manA1可以读写A1目录,并且可以读写groupB的所有子目录。
3、manA2可以读写A2目录,并且可以读写groupB的所有子目录。
4、manB1可以读写B1目录。
5、manB2可以读写B2目录。
6、如果一个用户没有某个目录的访问权限,那么该用户就不能看到此目录。
7、只允许manger用户和groupA、groupB组成员访问FTP服务器。
8、不允许任何人破坏主干目录结构

2、实现

(1)添加用户和组        

        useradd manager
        passwd manager
        groupadd groupA
        groupadd groupB
        useradd manA1
        passwd manA1
        usermod -G groupA manA1
        useradd manA2
        passwd manA2
        usermod -G groupA manA2
        useradd manB1
        passwd manB1
        usermod -G groupB manB1
        useradd manB2
        passwd manB2
        usermod -G groupB manB2

(2)配置文件
# This is a basic ProFTPD configuration file (rename it to 
# 'proftpd.conf' for actual use.  It establishes a single server
# and a single anonymous login.  It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName   "Formax BPO FTP Server"
ServerType   standalone
DefaultServer   on
# Port 21 is the standard FTP port.
Port    21
UseReverseDNS off
IdentLookups off# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask    000
# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances   30
# Set the user and group under which the server will run.
User    nobody
Group    nogroup
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
# DefaultRoot ~
DefaultRoot /ftproot
# Normally, we want files to be overwriteable.
AllowOverwrite  on
AllowStoreRestart on
ServerIdent off

<IfModule mod_tls.c>
      TLSEngine on
      TLSLog /var/ftpd/tls.log
      TLSProtocol SSLv23
      # Are clients required to use FTP over TLS when talking to this server?
      TLSRequired on
      # Server's certificate
      TLSRSACertificateFile /etc/proftpd.cert
      TLSRSACertificateKeyFile /etc/proftpd.key
      # CA the server trusts
      TLSCACertificateFile /etc/proftpd.cert
      # Authenticate clients that want to use FTP over TLS?
      TLSVerifyClient off
      TLSOptions NoCertRequest
      # Allow SSL/TLS renegotiations when the client requests them, but
      # do not force the renegotations.  Some clients do not support
      # SSL/TLS renegotiations; when mod_tls forces a renegotiation, these
      # clients will close the data connection, or there will be a timeout
      # on an idle data connection.
      TLSRenegotiate required off
</IfModule>
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
      DenyAll
</Limit>
<Limit LOGIN>
      AllowUser manager
      AllowGroup groupA
      DenyAll
      AllowGroup groupB
</Limit>

<Directory /ftproot/*>
     <Limit ALL>
          DenyAll
     </Limit>
</Directory>
<Directory /ftproot/manager>
     <Limit ALL>
          AllowUser manager
     </Limit>
</Directory>
<Directory /ftproot/groupA>
     <Limit DIRS>
          AllowUser manager
          AllowGroup groupA
     </Limit>
</Directory>
<Directory /ftproot/groupA/*>
     <Limit DIRS>
          DenyAll
     </Limit>
</Directory>
<Directory /ftproot/groupA/A2>
     <Limit DIRS READ WRITE>
          AllowUser manager
          AllowUser manA2
          DenyAll
     </Limit>
</Directory>
<Directory /ftproot/groupA/A1>
     <Limit DIRS READ WRITE>
          AllowUser manager
          AllowUser manA1
          DenyAll
     </Limit>
</Directory>
<Directory /ftproot/groupB>
     <Limit DIRS>
          AllowUser manager
          AllowGroup groupA
          AllowGroup groupB
     </Limit>
</Directory>
<Directory /ftproot/groupB/*>
     <Limit DIRS>
          DenyAll
     </Limit>
</Directory>
<Directory /ftproot/groupB/B1>
     <Limit DIRS READ WRITE>
          AllowUser manager
          AllowUser manB1
          AllowGroup groupA
          DenyAll
     </Limit>
</Directory>
<Directory /ftproot/groupB/B2>
     <Limit DIRS READ WRITE>
          AllowUser manager
          AllowUser manB2
          AllowGroup groupA
     </Limit>
</Directory>

参考:
1、[url]http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-Limit.html[/url]
2、[url]http://www.castaglia.org/proftpd/[/url]
3、[url]http://www.proftpd.org/[/url]










本文转自 h2appy  51CTO博客,原文链接:http://blog.51cto.com/h2appy/123997,如需转载请自行联系原作者
目录
相关文章
|
存储 Shell Android开发
Android--adb命令查看第三方应用包名、应用activity名
版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/78038767 (adb s...
6114 0
|
Linux 容器 Docker
Debian配置系统中文语言及环境
Debian配置系统中文语言及环境
18206 1
|
9月前
|
消息中间件 运维 Java
详解RabbitMQ1-基础使用
MQ异步通信技术摘要 MQ(消息队列)是一种异步通信方式,通过消息Broker实现生产者、消费者解耦。RabbitMQ作为主流MQ方案,支持多种交换机类型(Fanout广播、Direct路由、Topic主题)实现灵活消息路由。Spring AMQP简化了RabbitMQ集成,提供: 自动声明队列/交换机 注解式监听器 RabbitTemplate消息模板 核心优势包括降低耦合、提升性能、故障隔离,但也需考虑Broker可靠性问题。实际开发中需注意: 配置prefetch控制消费速率 使用JSON转换器替代默
|
3月前
|
人工智能 弹性计算 测试技术
阿里云轻量应用服务器38元1年什么配置?抢购入口在哪?没抢到怎么办?
本文围绕阿里云38元/年轻量应用服务器抢购活动展开完整解析,明确其2核2G、200M峰值带宽的配置细节、每日两场的抢购时段与镜像选择方案,梳理了抢购资格、入口与提升成功率的实操技巧。同时补充99元ECS经济型e实例、199元通用算力型u1实例两大高性价比替代方案,覆盖新老用户不同上云需求,为用户提供从限时抢购到长期稳定用云的完整选型参考。
|
5月前
|
测试技术 Android开发 iOS开发
Multiplatform:用一套声明式 UI 连接多端
Compose Multiplatform 是基于 Kotlin 的跨平台 UI 框架,延续 Jetpack Compose 声明式范式,支持 Android、iOS、桌面与 Web。它共享 UI 逻辑与状态,分层处理平台能力,适合工具类、中后台等 UI 高度一致的场景,助力 Android 团队高效拓展多端。(239 字)
346 0
|
6月前
|
数据采集 缓存 监控
1688 商品详情 API:实时获取 SKU 批发价与库存(Python 调用实战)
1688商品详情接口支持通过ID或链接实时获取SKU、阶梯批发价、活动价、库存等动态数据,适用于比价、监控、ERP同步。无需自研爬虫,规避风控;提供Python示例、分层缓存、轮询策略与容错机制,保障数据时效性与稳定性。
839 0
|
6月前
|
存储 人工智能 小程序
BROMPTON 与阿里云上的 Salesforce,一“骑”构建社群驱动的客户运营体系
BROMPTON 携手阿里云上的 Salesforce,构建以社群为中心的客户运营体系
|
11月前
|
存储 安全 Cloud Native
Rocky Linux下配置nfs
NFS(网络文件系统)是类Unix系统间分布式文件共享的核心协议,支持跨机器数据共享,广泛应用于云原生、企业文件服务。本文详解NFS在Rocky Linux下的部署:从基础概念、组件安装(nfs-utils、rpcbind)、服务器配置(/etc/exports)、防火墙设置到客户端挂载与自动加载(fstab、autofs),并提供常见问题排查方案,助力构建高效安全的共享存储环境。
|
存储 搜索推荐 物联网
RFID在汽车生产工艺环节的深度应用与价值体现
RFID技术凭借非接触识别、抗干扰强等优势,深度融入汽车制造四大工艺,实现生产全流程数字化追溯与精细化管理,助力车企提升效率、保障质量、降低成本,推动智能制造转型。