ProFTPD部署指南

简介:

 ProFTPD部署指南

 
服务器环境:RHEL5.4
下载ProFTP:
# wget ftp://ftp1.hk.proftpd.org/proftpd/distrib/source/proftpd-1.3.4a.tar.bz2
 
 
1.FTP要求:
  公司四个部门:运维部、开发部、销售部、行政部
  各部门用户访问FTP后可以看到所有目录,仅可以访问本部门的目录
  需要FTP日志功能
  FTP认证方式基于文件认证方式
  共享目录:/var/ftp
 
 
2.解压文件:
# tar  -xjf   proftpd-1.3.4a.tar.bz2  -C /usr/src/
# cd  /usr/src/proftpd-1.3.4a/
安装前请先阅读INSTALL与README文件
 
 
3.安装ProFTPD:
#./configure  --help 查看帮助选项
######################################################################################
以下为部分选项说明:        
--prefix=PREFIX 指定安装路径(--prefix=/usr/local/)        
--sysconfdir=DIR        指定FTP服务配置文件路径(--sysconfdir=/etc)        
--localstatedir=DIR     指定运行状态的文件存放位置(默认/var/proftpd)        
--with-modules=mod_ldap 指定加载功能模块        
--enable-memcache       支持缓存功能        
--enable-nls            支持多语言环境(如中文),安装完成后在主配置文件中需要指定字符编码(UseEncoding UTF-8 CP936)  
--enable-openssl        支持TLS加密FTP服务        
--enable-shadow 支持使用/etc/shadow验证用户密码        
######################################################################################################
 
 
注:需要GCC编译器
#./configure  --prefix=/usr/local/proftpd  --sysconfdir=/etc/  --enable-nls  --enable-openssl  --enable-shadow
#make
#make  install
#PATH=echo$PATH:/usr/local/proftpd/bin 添加环境变量
#useradd  -M -s /sbin/nologin  proftp
创建启动用户及组(该用户无法登录系统,没有宿主目录)
 
 
 
4.建立共享目录,修改配置文件:
 
#mkdir  -p  /var/ftp/{运维部,开发部,销售部,行政部}
#useradd -M -s /sbin/nologin  yunwei
#useradd -M -s /sbin/nologin  kaifa
#useradd -M -s /sbin/nologin  xiaoshou
#useradd -M -s /sbin/nologin  xingzheng
#chmod 777  /var/ftp/运维部
#chmod 777  /var/ftp/开发部
#chmod 777  /var/ftp/销售部
#chmod 777  /var/ftp/行政部
 
 
 
#vim  /etc/proftpd.conf     以下为配置文件原文(行号仅为参考值)
******************************************************************************************************
     1 # This is a basic ProFTPD configuration file (rename it to 
     2 # 'proftpd.conf' for actual use.  It establishes a single server
     3 # and a single anonymous login.  It assumes that you have a user/group
     4 # "nobody" and "ftp" for normal operation and anon.
     5
     6 ServerName "ProFTPD Default Installation"
                                         客户端连接后显示的字符
     7 ServerType standalone
                                         服务启动模式
     8 DefaultServer on
     9
    10 # Port 21 is the standard FTP port.
    11 Port 21 端口
    12
    13 # Don't use IPv6 support by default.
    14 UseIPv6 off 禁用IPv6
    15
    16 # Umask 022 is a good standard umask to prevent new dirs and files
    17 # from being group and world writable.
    18 Umask 022     权限掩码
    19
    20 # To prevent DoS attacks, set the maximum number of child processes
    21 # to 30.  If you need to allow more than 30 concurrent connections
    22 # at once, simply increase this value.  Note that this ONLY works
    23 # in standalone mode, in inetd mode you should use an inetd server
    24 # that allows you to limit maximum number of processes per service
    25 # (such as xinetd).
    26 MaxInstances 30      并发进程30个(防DoS攻击)
    27
    28 # Set the user and group under which the server will run.
    29 User nobody  启动服务的用户
    30 Group nobody  启动服务的组
    31
    32 # To cause every FTP user to be "jailed" (chrooted) into their home
    33 # directory, uncomment this line.
    34 #DefaultRoot ~ 共享根目录(默认为用户家目录)
    35
    36 # Normally, we want files to be overwriteable.
    37 AllowOverwrite on 是否允许使用文件覆写权限
    38
    39 # Bar use of SITE CHMOD by default
    40 <Limit SITE_CHMOD> 权限设置
    41   DenyAll
    42 </Limit>
    43
    44 # A basic anonymous configuration, no upload directories.  If you do not
    45 # want anonymous users, simply delete this entire <Anonymous> section.
    46 <Anonymous ~ftp>
    47   User ftp
    48   Group ftp
    49
    50   # We want clients to be able to login with "anonymous" as well as "ftp"
    51   UserAlias anonymous ftp 用户别名
    52
    53   # Limit the maximum number of anonymous logins
    54   MaxClients 10         最大客户端连接数
    55
    56   # We want 'welcome.msg' displayed at login, and '.message' displayed
    57   # in each newly chdired directory.
    58   DisplayLogin welcome.msg 显示登录信息
    59   DisplayChdir .message
    60
    61   # Limit WRITE everywhere in the anonymous chroot
    62   <Limit WRITE> 权限设置
    63     DenyAll
    64   </Limit>
    65 </Anonymous>
******************************************************************************************************
 
 
该文件格式:
##########################################################################
#   全局设置 参数值                                                   #
#   全局设置 参数值                                                   #
#                                                                        #
#   <Directory  "路径"> 指定路径相关设置,可以使用Limit语法限制目录权限  #
#         ... ...                                                        #
#   ... ...                                                        #
#   </Directory>                                                         #
#                #
#                                                                        #
#  #
#   <anonymouse "路径"> 匿名共享路径相关设置(包括权限设置)     #
#   </anonymouse>          #
##########################################################################
 
 
 
Limit权限说明:
#########################################################################
# CWD  : Change Working Directory 进入该目录  #
# MKD  : Make Directory 创建目录 #
# RNFR : Rename from 更名 #
# DELE : Delete 删除文件 #
# RMD  : Remove Directory 删除目录 #
# READ :  可读         #
# WRITE:  可写 #
# STOR :  可上传 #
# RETR :  可下载         #
# DIRS : 允许列出目录 #
# LOGIN: 允许登录 #
# ALL  :  全部 #
#########################################################################
 
 
 
 
修改后有效的配置文件内容,部分内容为添加内容(#开始的部分为注释):
 
     6 ServerName "ProFTPD Default Installation"
     7 ServerType standalone
     8 DefaultServer on
     9  UseEncoding UTF-8 CP936 支持的编码格式(中文)
    11 Port 21
    12  AllowRetrieveRestart on    允许断点继传(上传)
    13  AllowStoreRestart on    允许断点继传(下载)
    14 UseIPv6 off
    18 Umask 022
    19  RootLogin off 禁止root登录ftp
    26 MaxInstances 30
    27  SystemLog /var/log/proftp.log
                                                 产生独立的日志文件
    28 TransferLog /var/log/proftp.log
                                                 记录用户下载的日志信息
 
 #####如果想指定自己的日志格式可以结合(ExtendLog,LogFormat)两个选项设置
 
 
    29 User proftp   设置启动用户为proftp
    30 Group proftp   设置启动组为proftp
    34 DefaultRoot /var/ftp   指定共享根目录为/var/ftp
    37 AllowOverwrite on
    46 #<Anonymous ~ftp> 该部分全部#注释,取消匿名访问功能
    47 #  User ftp
    48 #  Group ftp
    51 #  UserAlias anonymous ftp
    54 #  MaxClients 10
    58 #  DisplayLogin welcome.msg
    59 #  DisplayChdir .message
    62 #  <Limit WRITE>
    63 #    DenyAll
    64 #  </Limit>
    65 #</Anonymous>
以下内容为设置权限,为手动添加内容
           所有用户可以看到所有部门的文件夹,仅可以访问自己部门的目录
*****************************************************************************************************
    67  RequireValidShell off 用户登录是否需要shell(对虚拟用户很重要)
    68  AuthUserFile /usr/local/proftpd/ftpd.passwd
                          通过文件认证用户登录,需要ftpasswd命令创建该文件
    69 <Directory "/var/ftp/*">
    70 <Limit CWD READ>  允许所有人可以查看根目录
    71 AllowAll
    72 </Limit>
    73 </Directory>
    74 <Directory "/var/ftp/运维部">
    75 <Limit CWD MKD RNFR READ WRITE STOR RETR>
    76 DenyAll  拒绝所有人往该目录下执行Limit后的操作指令
    77 </Limit> 
    78 <Limit DELE>
    79 DenyAll  禁止任何人在该目录下删除文件
    80 </Limit>
    81 <Limit CWD MKD RNFR READ WRITE STOR RETR>
    82 AllowUser yunwei 仅允许yunwei用户可以执行Limit后的所有指令
    83 </Limit> 
    84 </Directory>
    85 <Directory "/var/ftp/开发部">
    86 <Limit CWD MKD RNFR READ WRITE STOR RETR>
    87 DenyAll
    88 </Limit> 
    89 <Limit DELE>
    90 DenyAll
    91 </Limit>
    92 <Limit CWD MKD RNFR READ WRITE STOR RETR>
    93 AllowUser kaifa
    94 </Limit> 
    95 </Directory>
    96 <Directory "/var/ftp/行政部">
    97 <Limit CWD MKD RNFR READ WRITE STOR RETR>
    98 DenyAll
    99 </Limit> 
   100 <Limit DELE>
   101 DenyAll
   102 </Limit>
   103 <Limit CWD MKD RNFR READ WRITE STOR RETR>
   104 AllowUser xingzheng
   105 </Limit> 
   106 </Directory>
   107 <Directory "/var/ftp/销售部">
   108 <Limit CWD MKD RNFR READ WRITE STOR RETR>
   109 DenyAll
   110 </Limit> 
   111 <Limit DELE>
   112 DenyAll
   113 </Limit>
   114 <Limit CWD MKD RNFR READ WRITE STOR RETR>
   115 AllowUser xiaoshou
   116 </Limit> 
   117 </Directory>
******************************************************************************************************
 
 
 
5.创建虚机帐号
 
ftpasswd命令格式说明
(该命令可以创建用户文件、组文件,默认创建的用户文件为ftpd.passwd):
--passwd  创建密码文件,即AuthUserFile指定的文件
--group   创建组文件
--name   指定创建的用户名
--uid   指定用户虚拟UID
--gid     指定虚拟GID
--home   指定用户家目录
--shell   指定用户Shell
--file   指定创建的文件名
 
 
#ftpasswd  --passwd  --name=yunwei  --uid=1000  --home=/home/nohome  --shell=/bin/false
 
6.启动FTP服务:
 
#/usr/local/proftpd/sbin/proftpd
 
成功验证!!!!
这里仅以用户为实验环境,需要实现组功能的情况可以自行探索...
支持开源



















本文转自丁丁历险51CTO博客,原文链接:http://blog.51cto.com/manual/760048  ,如需转载请自行联系原作者

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
缓存 负载均衡 网络协议
Nginx安装及部署
Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,公开版本1.19.6发布于2020年12月15日。 其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、简单的配置文件和低系统资源的消耗而闻名。2022年01月25日,nginx 1.21.6发布。 Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,
Nginx安装及部署
|
Shell 数据安全/隐私保护
|
Apache 数据安全/隐私保护
|
Shell Apache Perl
|
Linux 网络安全
|
开发工具 数据安全/隐私保护 安全
|
Web App开发 前端开发 应用服务中间件