proftpd 安装

来源:互联网 发布:刻录光盘软件哪个好 编辑:程序博客网 时间:2024/05/20 21:18
 

 

 

 

Linux源码安装proftpd以及配置虚拟用户

一 实验环境 

Red Hat Enterprise Linux 5.3

 

二 .实验目的

 配置 proftp 虚拟用户,为不同的虚拟用户分配不同的权限

 

三 .所需软件

 proftpd-1.3.0.tar.bz2

 

四 . 用户权限

以四个用户为例

260804162: 上传

260804163: 下载

 

实验步骤

1 、检查安装 proftpd:

 #tar –jxvf proftpd-1.3.0.tar.bz2

 #cd proftpd-1.3.0

 

#./configure --prefix=/proftpd                 //--prefix 为安装路径 , 其他参数可参考 ”./configure --help”

 #make

 

#make install

 

2. 修改配置文件 , 在 /proftpd/etc/proftpd.conf 中加入

 

<Directory /ftproot>

 

  <Limit STOR>

 

DenyAll

 

AllowUser 260804162

 

    </Limit>

 

  <Limit RETR>

 

DenyAll

 

AllowUser 260804163

 

  </Limit>

 

</Directory>

 RequireValidShell off

 AuthOrder mod_auth_file.c

 AuthUserFile /proftpd/ passwd

 AuthGroupFile /proftpd/group

 

 

 

// 参数说明 :

 

<Directory  /ftproot/test>      ----------------- à 1 、继承性

     <Limit DIRS>        ------------------------- à 2 、优先级

          AllowUser  u1          -------------------- à 3 、访问控制的应用顺序

          DenyAll

      </Limit>

 </Directory>

 

 

AuthOrder                       mod_auth_pam.c* mod_auth_file.c           // 启用认证方式

 

AuthUserFile                    /etc/proftpd/ftpd.passwd                      //ftp 用户密码文件

 

AuthGroupFile                /etc/proftpd/ftpd.group                                     //ftp 用户组文件

 

 

其中, Directory 指定用户的文件夹 , Limit 分配了用户对文件夹的权限 ,AuthOrder 指定了权限检查的顺序。这里只使用虚拟用户。 AuthUserFile 和 AuthGroupFile 的文件格式看 passwd(5) 和 group(5) 。如果用户名和组名与系统的重复,看 DirFakeUser 和 DirFakeGroup 。

 

 

 

3. 使用 ftpasswd 创建 passwd 和 group 文件 (/proftpd-1.3.0/contrib/ftpasswd)

 

 # ftpasswd --passwd --file= /proftpd/passwd --name=260804162 --uid=2001

 

 --home=/ftproot --shell=/bin/false

 # ftpasswd --passwd --file= /proftpd/passwd --name=260804163 --uid=2002

 --home=/ftproot --shell=/bin/false

 创建了一个 260804162 和 260804163 用户

 

# ftpasswd --group --name=test --gid=2003

 创建了一个 test 组

 

# ftpasswd --group --name=test --gid=2003 --member=260804162 --member=260804163

 把 260804162 和 260804163 加入 test 组

 

 

 

注脚 :

 –passwd 指定建立一个新的虚拟用户, –group 则建立一个虚拟组;

–file 指定存储虚拟用户的文件;

–name 指定此虚拟用户的用户名,密码会在命令执行时要求输入;

–uid 指定此虚拟用户对应的系统用户 UID ,此虚拟用户将以此系统 UID 的身份读写文件

–home 指定此虚拟用户的根目录,就是其登陆 FTP 后的根目录;

–shell 指定此虚拟用户的 shell ,为了安全当然指定一个不可登陆的 shell 了。

 

4. 启动

proftpd

 

 #/proftpd/sbin/proftpd –c /proftpd/etc/proftpd.conf

 

 

 

5. 常用全局设置:

 

 DefaultRoot ~ # 限制每个 FTP 用户在自己的目录下,不可查看上一级目录

 

 AllowRetrieveRestart on # 下载时,允许断点续传

 

AllowStoreRestart on # 上传时,允许断点续传

 

ServerIdent off # 屏蔽服务器版本信息

 

TransferRate STOR   RETR 速度( Kbytes/s ) user 使用者 # 设定用户传输速率

 

MaxHostsPerUser 1 # 每个帐户最多允许来源 ip 为 1 个 , 对防止 ftp 帐号还是比较有用的。

 

 MaxClientsPerUser 1 # 每个帐户在每个客户端最多可以同时登陆 1 次 , 可以防止多线程软件下载对服务器的 破坏。

 

MaxClientsPerHost 1 # 同一个客户端只能最多 1 个帐号可以登陆

 

 WtmpLog on # 是否要把 ftp 记录在日志中,如果不想可以设置成 off 屏蔽掉 log 日志。

 

 TimeoutIdle 600 # 客户端 idle 时间设置,默认就是 600 秒

 

 DisplayLogin welcome.msg # 设置 ftp 登陆欢迎信息文件

 

 RootLogin on # 允许 root 用户登录,默认是不允许的,安全起见不推荐此选项。

 

 

 

6.proftpd 中的 limit 的参数说明

 

<Limit 限制动作 >;

 ...

 ...

 </Limit>;

CMD : Change Working Directory 改变目录

MKD : MaKe Directory 建立目录的权限

RNFR : ReName FRom 更改目录名的权限

DELE : DELEte 删除文件的权限

RMD : ReMove Directory 删除目录的权限

RETR : RETRieve 从服务端下载到客户端的权限

STOR : STORe 从客户端上传到服务端的权限

READ :可读的权限,不包括列目录的权限,相当于 RETR , STAT 等

WRITE :写文件或者目录的权限,包括 MKD 和 RMD

 DIRS :是否允许列目录,相当于 LIST , NLST 等权限,还是比较实用的

ALL :所有权限

LOGIN :是否允许登陆的权限

 

limit 中对用户和群组的控制 , 其实就是 ...

 

AllowUser 针对某个用户允许的 Limit

 DenyUser 针对某个用户禁止的 Limit

 AllowGroup 针对某个用户组允许的 Limit

 DenyGroup 针对某个用户组禁止的 Limit

 AllowAll 针对所有用户组允许的 Limit

 DenyAll 针对所有用户禁止的 Limit

 

Deny from 禁止 IP 来源

Deny all 允许 IP 来源

 

 

例子:

# 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   "ProFTPD Default Installation"
ServerType   standalone
DefaultServer   on

# Port 21 is the standard FTP port.
Port    21

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask    022

# 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 ~
#启用日志
LogFormat auth "IP:%a Name:%u At:%t UsedTime:%T"
LogFormat readwrite "IP:%a Name:%u byte:%b file:%F At:%t UsedTime:%T"
#以write的日志格式记录read,wreite的日志
ExtendedLog /home/test.log WRITE,READ readwrite
#以auth 的日志格式记录login的日志
ExtendedLog /home/test1.log AUTH auth

# Normally, we want files to be overwriteable.
AllowOverwrite  on

# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
  DenyAll
</Limit>
#限制目录及用户组信息
<Directory /home/ftp>
 <Limit WRITE>
 DenyGroup test
 </Limit>
</Directory>

AuthOrder mod_auth.pam.c* mod_auth_file.c
AuthUserFile /etc/proftpd/ftpd.passwd
AuthGroupFile /etc/proftpd/ftpd.group

 

# A basic anonymous configuration, no upload directories.  If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
<Anonymous ~ftp>
  User    ftp
  Group    ftp

  # We want clients to be able to login with "anonymous" as well as "ftp"
  #UserAlias   anonymous ftp

  # Limit the maximum number of anonymous logins
  MaxClients   10

  # We want 'welcome.msg' displayed at login, and '.message' displayed
  # in each newly chdired directory.
  DisplayLogin   welcome.msg
  DisplayFirstChdir  .message

  # Limit WRITE everywhere in the anonymous chroot
  <Limit WRITE>
    DenyAll
  </Limit>
</Anonymous>

 

 

原创粉丝点击