当前位置: > Linux服务器 > ftp >

linux上ftp服务器 proftp配置

时间:2016-07-17 22:41来源:linux.it.net.cn 作者:IT
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

技巧一、防止proftpd进行DNS反查以及对用户端进行ident确认

在proftpd.conf里面加入两行:

  1. UseReverseDNS off  
  2.  
  3. IdentLookups off  
  4.  

防止proftpd进行DNS反查以及对用户端进行ident确认。

===

技巧二、proftpd如何允许以root身份登录

在配置文件中使用下面的配置:

  1. RootLogin on  
  2.  

===

技巧三、如何让匿名用户使用proftpd服务器

建立一个用户,用户名为guest,然后在配置文件中使用下面的配置:

  1. AnonRequirePassword off  
  2.  
  3. User private  
  4.  
  5. Group private  
  6.  
  7. RequireValidShell off  
  8.  
  9. DenyAll  
  10.  

===

技巧四、如果要支持下载续传,那么必须指定:

  1. AllowRetrieveRestart on  
  2.  

如果要支持上传续传,那么必须指定:

  1. AllowOverwrite on  
  2.  
  3. AllowStoreRestart on  
  4.  

必须同时指定AllowOverwrite和AllowStoreRestart的原因是由于重新上传或者续传也是属于覆盖文件。

同时记得不要同时使用HiddenStor和AllowStoreRestart。

===

技巧五、通过ls看见以"."号开头的文件

在配置文件中设置:

  1. ShowDotFiles on  
  2.  

这样就能通过ls看见以"."号开头的文件

好好学习,天天吃饭

===

技巧六、proftpd如何实现磁盘限额

首先编译的时候指定--with-modules的时候要包含mod_quota。

然后在配置文件中使用:

  1. Quotas on  
  2.  
  3. QuotaCalc on  
  4.  
  5. DefaultQuota 8000  
  6.  
  7. QuotaBlockSize 1024  
  8.  
  9. QuotaBlockName kb  
  10.  

就可以实现磁盘限额。其中DefaultQuota说明用户只能用8000个block,而QuotaBlockSize则指明每个block大小是1024byte也就是1k。QuotaBlockName只在提示中出现,告诉用户block的单位。

===

  技巧七、proftpd环境下如何将用户限制在自己的home目录下?

修改proftpd.conf,加入

  1. DefaultRoot ~  
  2.  

(将用户限制在自己的目录下)

或者

  1. DefaultRoot ~ group1, !group2,!group3  
  2.  

(将用户限制在自己的目录下,对group1有效,对group2,group3无效)

===

技巧八、如何让proftpd只监听在特定IP

如果一台机器有两个或者多个IP,比如192.168.0.1和172.16.0.1,那么缺省情况下ftp到这两个ip都可以连上这个ftp server,有些情况下要求只能ftp到192.168.0.1而不能ftp到172.16.0.1,该如何处理呢?

在proftpd.conf里面设置:

  1. Bind 192.168.0.1  
  2.  
  3. SocketBindTight on  
  4.  

但是这个配置只能在standalone模式下面才能生效。

===

技巧九、proftpd中MaxClients和MaxInstances有什么不同

为了有效利用系统资源,防止过多连接,有时候可以在proftpd.conf里面有这样的配置:

  1. MaxClients 100  
  2.  

但是有时候却是看到这样的配置:

  1. MaxInstances 100  
  2.  

这两个有什么区别呢?

MaxInstances设置的是proftpd产生的子进程的个数,而MaxClients限制的是登录用户的个数。而客户端只要产生一个连接,即使不登录,也会导致proftpd产生一个子进程。

如果配置文件中限制MaxClients 100的时候,第101个连上的用户会被提示允许连接的客户端个数已达上限,同时断开连接。而设置MaxInstances 100的时候,第101个连接的用户不会得到任何提示,而服务器拒绝接受任何连接。

====

技巧十、Proftpd如何限制某个用户的同时连接数

Proftpd 1.2.7rc1以后提供了一个新参数-MaxClientsPerUser。在配置文件中添加下列参数:

 

  1. MaxClientsPerUser 5  

这样就能限制每个用户只能同时有5个连接,使用例如flashget等下载工具的时候就最多只能分成5块下载。

===

技巧十一、如何不用kill proftpd的进程而停止ftp服务

ftpshut命令可以使得管理员不用停止proftpd进程而禁止所有连接,同时送出停止的信息。而且可以做到定时停止、允许当前存在的连接是马上中断还是到用户自己中断。

要重新提供ftp服务只要删除/etc/shutmsg。

===

技巧十二、如何查看当前连接到proftpd的用户

使用ftpwho命令,可以查看当前连接的用户相关信息,比如客户端机器名、用户名、连接时间、当前状态、进程号等。比使用ps命令来查看方便多了。

===

技巧十三、ftpshut

这个程序的主要功能是生成文件/etc/shutmsg,也就是我们在前面/etc/ftpaccess中设定的shutdown命令,ftpshut的使用格式如下:

ftp <-l min> <-d min> time <说明>

各个参数的说明如下:

-l 这个参数设定在关闭FTP服务器功能前多长时间停止用户的连接;

-d 这个参数设定在关闭FTP服务器功能前多长时间将用户断线;

Time 这个参数指定关闭FTP服务器功能的时间,如想

在8点半关闭机器,这里可以写0830。

===

技巧十四、Proftpd如何设置允许非正常shell的用户登录

有时候系统里面有一些只有ftp权限的用户,他们的shell一般被设置成/bin/false来防止他们用telnet登录到系统,但是这样导致他们不能ftp,如何解决呢?

需要注释掉/etc/pam.d/ftp,注释掉下面一行:

  1. auth required /lib/security/pam_shells.so  
  2.  

同时在proftpd.conf里面加入:

  1. RequireValidShell off  
  2.  

===

技巧十五、Proftpd如何限速和设置发呆退出

可以使用:

  1. RateReadBPS RateReadFreeBytes  
  2.  
  3. RateWriteBPS RateWriteFreeBytes  
  4.  

来限制下载和上载速度:

RateReadBPS和RateWriteBPS限制下载和上载的速率

RateReadFreeBytes和RateWriteFreeBytes限制当用户现在这么多数据量以后再进行限速,这样可以实现对于小文件不限速,而大文件限速。

TimeoutIdle -- 设置空闲连接超时时钟

TimeoutLogin -- 设置空闲登陆超时时钟

TimeoutNoTransfer -- 设置当没有数据传输时的超时时钟

TimeoutStalled -- 设置被阻塞的下载的超时时钟

 

 

 

 

############################################################################# ServerName "LittleBoy" ServerType standalone DefaultServer on #隐藏服务器版本信息 ServerIdent off #FTP使用的端口,21是默认 Port 21 ############################################################################### ################################################################################### RequireValidShell off AuthPAM off AuthPAMConfig ftp ############################################################################### ############################################################################### #续传文件 AllowRetrieveRestart on AllowStoreRestart on #超时限制 TimeoutNoTransfer 600 TimeoutStalled 600 TimeoutIdle 1200 #设置最大尝试次数 #MaxLoginAttempts 3 #防止DoS攻击,设置最大子进程数为20.如果你要一次多于这个进程数,增加下面的值 #这个设置只有standalone 时有效,在inetd模式你应设置inetd服务器的每个服务数 #量进程数,例如xinetd MaxInstances 20 ############################################################################### #掩码 Umask 022可以有效地防止文件被其他用户或同组用户改写 Umask 022 #磁盘配额 #Quotas on #上传与下载比率 #Ratios on ############################################################################### # Set the user and group under which the server will run. User proftpd Group proftpd #禁止root登录 #RootLogin off #DefaultRoot ~ #禁止系统普通用户登录 #<Limit LOGIN> # DenyAll #</Limit> ############################################################################### ############################################################################### #启用日志 LogFormat auth "IP:%a Name:%u PASSWD:%A %r At:%t" LogFormat readwrite "IP:%a Name:%u PASSWD:%A %m %F At:%t UsedTime:%T" #以write的日志格式记录READ,WRITE的日志 ExtendedLog /var/log/proftpd/transfer.log WRITE,READ readwrite #以auth的日志格式记录LOGIN的日志 ExtendedLog /var/log/proftpd/login.log AUTH auth ##根据自己的需要定制: ## %a:客户ip ## %A:匿名用户名 ## %b:发送请求的字节数 ## %d:目录名(相对路径) ## %D:目录名(绝对路径) ## %f:上传或下载的文件名(绝对路径) ## %F:上传或下载的文件名(相对路径) ## %h:客户的域名 ## %L:本服务器ip ## %m:客户发送的命令 ## %p:本服务器的端口 ## %P:服务进程的id ## %r:客户发送的整条命令 ## %t:本地时间 ## %T:传送文件所用的时间(秒) ## %u:客户登陆的用户名 ############################################################################### ############################################################################### #一个基本的匿名帐号,带有上传目录 <Anonymous /home/ftp> RequireValidShell no User ftp Group ftp # 用 "anonymous" 代替 "proftpd" 登录 UserAlias anonymous ftp AnonRequirePassword off # Cosmetic changes, all files belongs to ftp user DirFakeUser on ftp DirFakeGroup on ftp # 限制每个匿名帐号连接数 MaxClients 10 "最大连接10达到了,你等会再来" MaxClientsPerHost 3 "对不起,一个IP只允许3个连接" #下载与上传速率的设置,单位为KByte/s TransferRate RETR 4000 user ftp TransferRate STOR 2000 user ftp #登录时的欢迎信息 DisplayLogin .welcome.msg #对这个服务器的根目录下的所有的子目录限制写操作 <Limit WRITE> DenyAll </Limit> #开匿名上传目录,只能上传而不能下载及修改原有文件 <Directory upload> Umask 022 022 <Limit READ WRITE> DenyAll </Limit> <Limit MKD STOR> AllowAll </Limit> </Directory> </Anonymous>

 
 
 
 

1、ProFTP下的参数说明:

CWD: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:是否允许登陆的权限

2、limit说明

AllowUser 针对某个用户允许的Limit

DenyUser 针对某个用户禁止的Limit

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

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

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

DenyAll 针对所有用户禁止的Limit

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

 

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

 

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

ProFTPD是针对Wu-FTP的弱项而开发的,除了改进的安全性,还具备许多Wu-FTP没有的特点,能以 Stand-alone、xinetd模式运行等。ProFTP已经成为继Wu-FTP之后最为流行的FTP服务器软件,越来越多的站点选用它构筑安全高效的FTP站点,ProFTP配置方便,并有MySQL和Quota模块可供选择,利用它们的完美结合可以实现非系统账号的管理和用户磁盘的限制。 
一、 ProFTPD服务面临的安全隐患 
ProFTPD服务面临的安全隐患主要包括:缓冲区溢出攻击(Buffer Overflow)、数据嗅探和匿名访问缺陷。 
1、缓冲区溢出攻击 
长期以来,缓冲区溢出已经成为计算机系统的一个问题。利用计算机缓冲区溢出漏洞进行攻击的最著名的案例是莫里斯蠕虫,发生在1988年11月。但即使其危害人所共知,缓冲区溢出仍然是现在入侵的一个重要手段。缓冲区溢出的概念:缓冲区溢出好比是将一百公斤货物放进一个只能装十公斤的容器里。 
缓冲区溢出漏洞是一个困扰了安全专家30多年的难题。简单来说,它是由于编程机制而导致的、在软件中出现的内存错误。这样的内存错误使得黑客可以运行一段恶意代码来破坏系统正常地运行,甚至获得整个系统的控制权。 
2、数据嗅探 
FTP 是传统的网络服务程序,在本质上是不安全的,因为它们在网络上用明文传送口令和数据,别有用心的人非常容易就可以截获这些口令和数据。而且,这些服务程序的安全验证方式也是有其弱点的,就是很容易受到"中间人"(man-in-the-middle)这种方式的攻击。 
所谓"中间人"的攻击方式,就是"中间人"冒充真正的服务器接收你传给服务器的数据,然后再冒充你把数据传给真正的服务器。服务器和你之间的数据传送被"中间人"转手后做了手脚之后,就会出现很严重的问题。截获这些口令的方式主要为暴力破解。另外使用sniffer程序监视网络封包捕捉FTP开始的会话信息,便可顺手截获root密码。 
3. 匿名访问缺陷 
匿名访问方式在FTP服务当中被广泛的支持,但是由于匿名FTP不需要真正的身份验证,因此很容易为入侵者提供一个访问通道,配合缓冲区溢出攻击,会造成很严重的后果。 
4. 拒绝服务攻击 
拒绝服务是一种技术含量低,但攻击效果明显的攻击方式,受到这种攻击时,服务器或网络设备长时间不能正常提供服务,并且由于某些网络通讯协议本身固有的缺陷,难以提出一个行之有效的解决办法。防范拒绝服务攻击需要我们从全局去部署防御拒绝服务攻击策略,多种策略联动防范,将拒绝服务攻击的危害降至最低。 
二、 加固ProFTPD服务端 
1.升级版本 
升级陈旧的ProFTPD版本,因为早期的ProFTPD版本存在的安全漏洞。对于一个新配置的ProFTPD服务器来说使用最新稳定版本是最明智的选择,可以在其官方网站下载其源代码进行编译。ProFTPD最新版本是1.2.10,官方网址:http://www.ProFTPD.org 。 
2.使用xinetd方式运行ProFTPD 
ProFTPD能以Stand-alone、xinetd两种模式运行,当用户账号比较少又经常需要连接到ProFTPD服务器时推荐使用xinetd模式运行。使用xinetd方式运行ProFTPD可以有效防范DoS攻击。 
从传统的守护进程的概念可以看出,对于系统所要通过的每一种服务,都必须运行一个监听某个端口连接所发生的守护进程,这通常意味着资源浪费。为了解决这个问题,一些Linux引进了"网络守护进程服务程序"的概念。 
Redhat Linux 8.0以后的版本使用的网络守护进程是xinted(eXtended InterNET daemon)。和stand-alone模式相比xinted模式也称 Internet Super-Server(超级服务器)。xinetd能够同时监听多个指定的端口,在接受用户请求时,他能够根据用户请求的端口不同,启动不同的网络服务进程来处理这些用户请求。 
可以把xinetd看做一个管理启动服务的管理服务器,它决定把一个客户请求交给那个程序处理,然后启动相应的守护进程。xinetd模式工作原理见图1。 
 
图1 xinetd模式网络服务 
和 stand-alone工作模式相比,系统不想要每一个网络服务进程都监听其服务端口。运行单个xinetd就可以同时监听所有服务端口,这样就降低了系统开销,保护系统资源。但是对于访问量大、经常出现并发访问时,xinetd想要频繁启动对应的网络服务进程,反而会导致系统性能下降。察看系统为 Linux服务提供那种模式方法在Linux命令行可以使用pstree命令可以看到两种不同方式启动的网络服务。 
xinetd提供类似于inetd+tcp_wrapper的功能,但是更加强大和安全。能有效的防止拒绝服务攻击(Denial of Services): 
1、限制同时运行的进程数。 
通过设置instances选项设定同时运行的并发进程数: 
instances=20 
当服务器被请求连接的进程数达到20个时,xinetd将停止接受多出部分的连接请求。直到请求连接数低于设定值为止。 
2.限制一个IP地址的最大连接数: 
通过限制一个主机的最大连接数,从而防止某个主机独占某个服务。 
per_source=5 
这里每个IP地址可以连接单个IP地址的连接数是5个。 
3.限制负载。 
xinetd还可以使用限制负载的方法防范拒绝服务攻击。用一个浮点数作为负载系数,当负载达到这个数目的时候,该服务将暂停处理后续的连接: 
max_load = 2.8 
上面的例子中当一项系统负载达到2.8时,所有服务将暂时中止,直到系统负载下降到设定值以下。说明要使用这个选项,编译时要加入–with- loadavg ,xinetd将而已处理max-load配置选项。从而在系统负载过重时关闭某些服务进程,来实现某些拒绝服务攻击。 
4.限制所有服务器数目(连接速率) 。 
xinetd可以使用cps选项设定连接速率,下面的例子: 
cps = 25 60 
第一个参数表示每秒可以处理的连接数,如果超过了这个连接数之后进入的连接将被暂时停止处理;第二个参数表示停止处理多少秒后继续处理先前暂停处理的连接。即服务器最多启动25个连接,如果达到这个数目将停止启动新服务60秒。在此期间不接受任何请求。 
使用xinetd方式运行ProFTPD的步骤: 
(1)检查确省运行情况 
确省情况下ProFTPD以stand-alone工作模式运行,可以使用"ps aux| grep proftpd"命令查看进程号,然后使用kill命令中止运行。 
(2)修改配置文件 
修改/etc/proftpd.conf文件的ServerType选项由"standalone"改为"inetd"。 
(3)建立用户组 
groupadd nogroup 
(4)创建配置文件/etc/xinetd.d/proftpd,代码如下:

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

service ftp 

flags = REUSE socket_type = 
stream instances = 30 cps = 
25 60max_load = 3.0wait = 
no user = root server = 
/usr/local/sbin/proftpd log_on_success = 
HOST PID log_on_failure = 
HOST RECORD disable = no 
}

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

5)重新启动xinetd配置 
killall -USR1 xinetd 
(6)使用命令连接服务器 
可以使用"ftp localhost"连接本地服务器,如果连接被拒绝,可以使用命令: 
tail -f /var/log/messages 
查看错误信息。 
3.隐藏ProFTPD服务器版本信息 
通常软件的BUG信息是和特定版本相关的,因此版本号是黑客寻求最有价值的信息。隐藏ProFTPD版本号比较简单,修改配置文件:

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

/etc/Proftpd.conf: 
ServerIdent off

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

4.伪装ProFTPD服务器 
Windows下的FTP服务多是Serv-U,可以把ProFTPD伪装为Serv-U,方法是修改配置文件proftpd.conf,添加如下内容: 
ServerIdent on \"Serv-U FTP 
Server v5.0 for WinSock ready…\" 
存盘退出后,重新启动proftpd服务,登录到修改了提示信息的FTP服务器进行测试:

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

C:\\>ftp 192.168.0.1Connected to 
192.168.0.1.220 Serv-U FTP Server 
v5.0 for WinSock ready… 
User (192.168.0.1:(none)): 
331 Password required for (none). 
Password: 530 Login incorrect. 
Login failed. 
ftp > quit 221 Goodbye.

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

这样从表面上看,服务器就是一个运行着Serv-U的Windows了。 
5. 使用非root权限运行ProFTPD 
以非root权限运行ProFTPD。修改配置文件:

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

/etc/Proftpd.conf: 
User nobody

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

#设置FTP服务以nobody运行 Group nogroup 
#注意:原来是"Group nobody",一定要改为"Group nogroup " 
上面的配置表示以nobody用户身份运行ProFTPD服务器。使用nobody身份运行能够降低缓冲区溢出攻击所带来的危险。 
6.监控ProFTPD服务器运行情况 
通常新部署一个ProFTPD服务器之后需要进行一段时间的监控:记录FTP连接记录、谁连接到我的FTP服务器。Proftpd本身附带了几个命令可以使用。 
(1)记录FTP连接数 
使用usr/local/bin/ftpcout命令,可以显示FTP服务器连接用户数量信息。 我们还可以使用watch命令配合使用,运行下面命令:

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

watch -n 360 /usr/local/bin/ftpcount

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

这个命令每三百六十秒显示一次连接用户数量的信息。 
(2)查找谁与FTP服务器连接 
使用usr/local/bin/ftpwho命令可以显示谁连接到FTP服务器。一个简单的输出如下:

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

Master proftpd process 8322: 
8387 0m1s proftpd: sheila – 
reboot.intevo.com: IDLE 8341 
3m59s proftpd: kabir – 
k2.intevo.com: IDLE – - 2 users

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

以上输出显示有两个用户(sheila和kabir)从不同的计算机连接到FTP服务器,输出内容还包括:为这些用户服务的ProFTPD的进程和主ProFTPD的进程ID。 
7.修改配置文件加固服务器 
ProFTPD使用的配置文件和Apache类似: 
单线指令:ServerName 和 ServerType 
多线容器指令:和 
如果以前配置过Apache的话,会很容易掌握。Proftpd服务器配置文件etc/Proftpd.conf中的许多选项可以加固服务器。 
(1)通过IP地址限制FTP访问 
假设要允许主机名称myhost.domain.com访问FTP服务器,首先使用命令: 
Ping myhost.domain.com 
假设等到IP地址是:216.112.169.138。下面修改配置文件,加入以下内容:

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

<Limit LOGIN>Order Allow, 
DenyAllow from 216.112.169.138Deny 
from all</Limit>

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

注意不要在Allow命令后直接使用主机名称,因为检查主机名称会降低服务器的运行速度。另外主机名称比IP地址更具有欺骗性。如果 myhost.domain.com没有固定IP地址,主机用户在下一次从ISP获得一个IP地址时就无法和FTP服务器连接。这时必须给整个网络授予 FTP访问的权限。命令如下:"Allow from 216.112.169." 。 
(2)使用PAM作为ProFTPD授权用户的鉴别方法 
ProFTPD可以加入嵌入式认证模块,成为PAM-aware的FTP服务器。PAM全称:Pluggable Authentication Module(嵌入式认证模块)。 
它最初有SUN公司开发;很快被Linux社区的接受,并且开发了更多的模块。其目标是提供一套可用于验证用户身份的函数库,从而将认证从应用程序开发中独立出来。PAM工作原理见用SRP建立安全的Linux Telnet服务器(链接:http://tech.ccidnet.com/art/302/20050915/333529_1.html )一文。 
下面手工建立一个/etc/pam.d/ftp文件包括以下内容:

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

%PAM-1.0 auth required 
/lib/security/pam_listfile.so 
item=user \ sense=deny 
file=/etc/ftpusers 
onerr=succeed auth required 
/lib/security/pam_stack.so 
service=system-auth auth 
required /lib/security/ 
pam_shells.so account required 
/lib/security/pam_stack.so 
service=system-auth session 
required /lib/security/pam_stack.so 
service=system-auth

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

每一行包括以下内容: 
module- type(模块类型) control-flag(控制字) module-path(模块路径) module-args(模块参数)。以上四个选项我们主要介绍module-type(模块类型)和control-flag(控制字),见表-1、表-2: 
表-1 PAM模块类型 
 
(3)对FTP用户使用chroot 
ProFTPD服务器要限制普通FTP用户可以访问的目录,配置很简单,如果限制skate组的skate用户登录时不能切换到其他目录,修改配置文件加入一行: 
DefaultRoot ~ skate,skate 
这样他只能呆在自己的home目录中。 
(4)限制FTP命令特权 
l 禁止一些用户创建和删除目录的特权 
如果发现一些用户有威胁行为,可以把他放在一个特定组中(badusers)使用如下的配置: 
<Directory /*> 
<Limit MKD RMD> 
Order deny,allowDenyGroup badusersAllowAll 
</Limit></Directory> 
这样除了那个特定的用户组之外,其他用户可以创建和删除目录。建立只能上载的FTP服务器,如果要建立一个只能上载的FTP服务器,在主服务器或者虚拟主容器中使用如下配置: 
<Directory /*> <Limit RETE> 
DenyAll 
</Limit> </Directory> 
限制对单个目录的访问。 
<Directory /*> <Limit CWD> 
DenyAll 
</Limit> </Directory> 
这样相应的FTP用户就不能更改目录。如果使用DenyGroup groupname代替DenyAll ,将配置范围限定在/etc/group文件中定义的groupname用户组中。 
限制目录浏览特权 
<Directory /my/mp3s> 
<Limit DIRS> 
DenyGroup newfriends 
</Limit> 
</Directory> 
以上配置可以限制/my/mp3s目录中名为newfriends组的目录浏览特权。这样可以防止他得到/my/mp3s目录的列表。 
(5)控制FTP命令缓冲区大小 
许多黑客通过发送一个大尺寸的命令攻击FTP服务器,希望造成服务器缓冲区溢出。可以在使用CommandBufferSize命令可以限制客户端命令长度。通常设定为512。 
(6)修改ProFTPD服务器使用端口 
ProFTP如果使用Stand-alone模式,可以通过设置proftpd.conf来控制它。使用不同端口的设置也较为简单,只需在proftpd.conf中将"Port xx"改为需要的值即可。 
(7)使不同用户之间相互隔离 
通常访问ISP的FTP服务器时,会看到一些不应当的系统信息,因此隐藏这些信息是必要的,下面是一个配置:

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

DefaultRoot "/www" 
<Directory /www> 
HideNoAccess on 
<Limit ALL> 
IgnoreHidden on 
</Limit> </Directory>

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

HideNoAccess指令将用户隐藏/www 目录下的所有条目,IgnoreHidden指令指示ProFTPD 服务器忽略用户所有指令。 
8.建立一个安全的匿名ProFTPD站点 
如果人们只需要从FTP服务器等到一些小文件(几兆),可以使用Apache web服务器代替匿名FTP站点。如果要通过一个匿名账号频繁上传、下载文件,就要建立一个安全的ProFTPD服务器。下面是配置文件/etc /proftpd.conf内容(其中incoming目录容许用户上传文件):

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
引用:
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

<Anonymous ~ftp> 
User ftp Group ftp RequireValidShell 
off UserAlias anonymous 
ftp MaxClients 40 
<Directory *> 
<Limit WRITE> 
DenyAll 
</Limit> 
</Directory> 
<Directory incoming> 
<Limit WRITE> 
AllowAll 
</Limit> 
<Limit READ> 
DenyAll 
</Limit> 
</Directory> 
</Anonymous>

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

根据以上内容建立的ProFTPD服务器会为自动连接到匿名ProFTPD服务器的用户创建一个chroot限制,用户的主目录为站点的根目录。下面解释主要配置指令的作用: 
User 和 Group:这两个指令确保User ftp和Group ftp拥有所有匿名会话。 
RequireValidShell:由于在/etc/passwd中没有用户FTP的有效列表,所以该指令说明ProFTPD允许User ftp的匿名会话。 
UserAlias:该指令把anonymous赋予FTP账号,以便所有用户可以使用ftp和anonymous作为用户名登录匿名FTP服务器。 
MaxClients:这里限制匿名连接数目是40,你可以根据系统负载设定连接数目。 
容器:这些容器给定目录的各种限制: 
第一个目录容器对每个用户和每个目录禁止写权限(包括上传、删除和修改)。 
第二个目录容器在incoming子目录中给每个用户写权限。 
最后一个Limit指令确保在incoming子目录中上传文件的用户不能查看和恢复目录中的文件。 
三、安全使用客户端工具 
以上已经安全加固了服务器端,要防范网络嗅探,即客户端向服务器传输数据过程的安全:防范网络嗅探的关键的文件传输过程,使用SSH上传数据到 ProFTPD服务器可以把所有传输的数据进行加密,这样即使网络中的黑客能够劫持用户所传输的数据,如果不能解密的话,也不能对数据传输构成真正的威胁。 
SSH有很多功能,它既可以代替Telnet,又可以为FTP、POP提供一个安全的"传输通道"。在不安全的网路通信环境中,它提供了很强的验证(authentication)机制与非常安全的通信环境。Linux下基于SSH的工具有:命令行和图形界面两种。

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

1. 命令行 
笔者是系统管理员所以喜欢前者主要工具是:用 sftp 命令,sftp工具可以用来打开一次安全互动的 FTP 会话。它与 ftp 相似, 只不过,它使用安全、加密的连接。它的一般语法是:sftpusername@hostname.com。一旦通过 验证,你可以使用一组和使用 FTP 相似的命令。SFTP相关命令的使用方法如下: 
 
2.图形界面工具:gFTP 
如果你使用命令行感觉比较繁琐。这里我们介绍一个安全快捷的数据传输工具:gFTP,它可以和SSH整合在一齐,提供一个图形化的加密传输方案。gFTP是一个多线程的FTP客户端,用GTK+编写。它支持多个线程同时下载,支持断点续传,支持FTP、HTTP和SSH协议,支持FTP和HTTP代理,可以下载整个目录,支持文件队列,支持缓存,支持拖拽操作,是一个很好的FTP客户端管理器。 
许多Linux发行版本都带有gFTP,也可以在其官方网址(http://www.gftp.org/ )下载。gFTP工作界面见图。使用方法在gftp登录界面上,选择gftp 下拉菜单 FTP-> Options(选项),在弹出的窗口中,选择SSH选项卡,在SSH2 sftp-server path框中填写/usr/libexec/openssh;并勾选Need SSH User/Pass;点击Save(保存)按钮,保存设置。 设置好后,在gftp登录界面上、登录密码后面的下拉菜单中选择SSH2。 
此时,输入远程主机名(或IP地址)、端口(22)、用户名、密码,按左侧的连接按钮,即可登录成功。这种方式对于登录匿名ftp服务服务器很有用。

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>

 
图 gFTP工作界面 
另外如果使用Windows的话推荐使用Filezilla ,它是客户端使用SFTP的一款不错的开源软件,对中文支持很好。最新版本2.2.16,官方网址:http://filezilla.sourceforge.net/ 。使用它可以安全方便的向ProFTPD服务器上传下载数据。 
总结:在众多网络应用中,FTP(文件传输协议)有着非常重要的地位。互联网一个十分重要的资源就是软件资源,而各种各样的软件资源大多数都放在FTP服务器中。系统管理员应当使安全保护方法对用户尽可能的简单。网络管理员要建立合理的用户痛苦量(痛苦量是指安全限制引起的抵制的函数)。以上从服务器到客户端介绍如何加固FTP应用。

<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; -webkit-text-decorations-in-effect: none;"></span></span></span></span>
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><br></span></span></span>
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"><br></span></span></span>
<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; white-space: normal; color: #4b4b4b;"><span style="text-decoration: underline;"><span color="#800080" style="color: #800080;"> 安装配置一个proftpd的实例</span></span></span>

安装配置一个proftpd的实例 
http://www.chinaunix.net

目的:

安装配置一个proftpd,达到以下要求 
1  不允许匿名访问。 
2  开放一个帐号,只有在upload目录有上传权限,可以续传,不能改名和删除。

操作: 
0  切换到root帐户 
[code:1:de92f96787]   su root //输入root的密码。 
[/code:1:de92f96787] 
1  下载proftpd 
地址:www.proftpd.org。这里我们下载了1.2.9版本 
[code:1:de92f96787]    wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.9.tar.gz 
[/code:1:de92f96787] 
2  安装proftpd 
切换到下载目录,假设为/tmp/proftpd,然后 
[code:1:de92f96787]    tar zxvf proftpd-1.2.9.tar.gz //解压 
    cd proftpd-1.2.9 
    ./configure --prefix=/var/proftpd --sysconfdir=/etc  //设置安装目录/var/proftpd,配置文件目录/etc 
    make 
    make install 
[/code:1:de92f96787] 
3  新建ftp专用帐号 
就是上面目的中提到的那个专用帐号,这里以skate/skate(u/p)为例。 
[code:1:de92f96787]    groupadd skate 
    useradd  skate -g skate -d /var/ftp  -s /sbin/nologin //设置/var/ftp目录为ftp的目录 
    passwd skate //设置skate用户的密码 
   mkdir /var/ftp/upload 
    chown skate.skate /var/ftp/upload  //设置upload目录skate用户可写 
[/code:1:de92f96787] 
4  设置proftpd 
proftpd的配置文件就一个,就是/etc/proftpd.conf 
[code:1:de92f96787]    vi /etc/proftpd.conf //打开proftpd.conf 
[/code:1:de92f96787] 
[code:1:de92f96787] 
####具体配置如下###### 
ServerName                      "Test ftp server..." 
ServerType                      standalone 
DefaultServer                   on 
#端口 
Port                            21 
Umask                           022 
#最大线程数 
MaxInstances                    30 
User                            skate 
Group                           skate

#DNS反查 
UseReverseDNS off 
IdentLookups off 
#最大尝试连接次数 
MaxLoginAttempts 3 
#每用户线程 
MaxClientsPerHost 2 
#最大用户数 
MaxClients 20

DirFakeUser On skate 
DirFakeGroup On skate 
DeferWelcome On 
#日志文件位置 
SystemLog /var/log/proftpd.log 
ServerIdent off

#限制skate组的skate用户登录时不能切换到其他目录(只能呆在他的home目录) 
DefaultRoot ~ skate,skate

#设置只允许192.168.0的用户登录 
#<limit LOGIN> 
#Order allow,deny 
#Allow from 192.168.0. 
#Deny from all 
#</limit>

#设置只允许skate用户登录,否则系统用户也可以登录ftp 
#<limit LOGIN> 
#Order allow,deny 
#DenyUser !skate 
#</limit>


#开起全盘的写权限 
<Directory /> 
  AllowOverwrite                on 
  AllowStoreRestart             on 
#允许FXP 
#  AllowForeignAddress             on 
<Limit All> 
AllowAll 
</Limit> 
</Directory>

#设置skate用户在upload的限制 
#DELE删除权限 
#RNFR RNTO重命名权限 
#RMD XRMD移动目录权限 
<Directory /var/ftp/upload> 
<Limit DELE RNFR RNTO RMD XRMD > 
 DenyUser skate 
</Limit> 
</Directory> 
#####结束###### 
[/code:1:de92f96787]

编辑完以后按Esc,然后输入:x保存。

5  启动服务 
编辑一个启动脚本(这个是从网上copy的,不是我写的,感谢那个写这个脚本的人,很好用,thx) 
[code:1:de92f96787]    vi /etc/rc.d/init.d/proftpd[/code:1:de92f96787] 
[code:1:de92f96787] 
#####脚本内容开始######## 
#!/bin/sh 

# Startup script for ProFTPD 

# chkconfig: 345 85 15 
# description: ProFTPD is an enhanced FTP server with \ 
#              a focus toward simplicity, security, and ease of configuration. \ 
#              It features a very Apache-like configuration syntax, \ 
#              and a highly customizable server infrastructure, \ 
#              including support for multiple 'virtual' FTP servers, \ 
#              anonymous FTP, and permission-based directory visibility. 
# processname: proftpd 
# config: /etc/proftpd.conf 

# By: Osman Elliyasa <osman@Cable.EU.org> 
# $Id: proftpd.init.d,v 1.7 2002/12/07 21:50:27 jwm Exp $

# Source function library. 
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/proftpd ]; then 
      . /etc/sysconfig/proftpd 
fi

#下面这行设置环境变量,注意设置好你的proftpd的安装目录 
PATH="$PATH:/usr/local/sbin:/var/proftpd/bin:/var/proftpd/sbin"

# See how we were called. 
case "$1" in 
        start) 
                echo -n "Starting proftpd: " 
                daemon proftpd $OPTIONS 
                echo 
                touch /var/lock/subsys/proftpd 
                ;; 
        stop) 
                echo -n "Shutting down proftpd: " 
                killproc proftpd 
                echo 
                rm -f /var/lock/subsys/proftpd 
                ;; 
        status) 
                status proftpd 
                ;; 
        restart) 
                $0 stop 
                $0 start 
                ;; 
        reread) 
                echo -n "Re-reading proftpd config: " 
                killproc proftpd -HUP 
                echo 
                ;; 
        suspend) 
                hash ftpshut >/dev/null 2>&1 
                if [ $? = 0 ]; then 
                        if [ $# -gt 1 ]; then 
                                shift 
                                echo -n "Suspending with '$*' " 
                                ftpshut $* 
                        else 
                                echo -n "Suspending NOW " 
                                ftpshut now "Maintanance in progress" 
                        fi 
                else 
                        echo -n "No way to suspend " 
                fi 
                echo 
                ;; 
        resume) 
                if [ -f /etc/shutmsg ]; then 
                        echo -n "Allowing sessions again " 
                        rm -f /etc/shutmsg 
                else 
                        echo -n "Was not suspended " 
                fi 
                echo 
                ;; 
        *) 
                echo -n "Usage: $0 {start|stop|restart|status|reread|resume" 
                hash ftpshut 
                if [ $? = 1 ]; then 
                        echo '}' 
                else 
                        echo '|suspend}' 
                        echo 'suspend accepts additional arguments which are passed to ftpshut(8)' 
                fi 
                exit 1 
esac

if [ $# -gt 1 ]; then 
        shift 
        $0 $* 
fi

exit 0 
#######脚本结束######### 
[/code:1:de92f96787] 
按Esc,输入:x保存。

然后添加到系统服务并启动 
[code:1:de92f96787] 
    chkconfig --add profptd 
    service proftpd start[/code:1:de92f96787] 
以后可以用service proftpd restart来重起proftpd。

6  一点体会 
看proftpd的文档翻译过的一句话:Finally, a special command is allowed which can be used to control login access: LOGIN Connection or login to 

the server. Applying a <Limit> to this pseudo-command can be used to allow or deny initial connection or login to the context. It has no 

effect, and is ignored, when used in a context other than server config, <VirtualHost> or <Anonymous> (i.e. using it in a <Directory> context 

is meaningless). 

翻译下:最后,有一个用来限制登陆的特殊命令,就是LOGIN。在<limit>中用这个,可以禁止或者允许连接进来。但是,如果不在Server config,<VirtualHost> 

或者<Anonymous>中使用的话,他将失去效用,或者说被忽略掉(比如在<Directory>中使用就是无效的)。

proftpd感觉还是比vsftp功能配置上好用一点,主要掌握好<limit>段基本上应用来说就没有问题了。 
proftpd文档地址http://www.proftpd.org/docs/。[/code]

 
 
 
一、测试平台
Debian 4.0r3
Proftpd 1.3.1 (WITH SSL)
<span class="Apple-style-span" style="font-family: 宋体, Arial; line-height: 18px; white-space: normal; font-size: 12px;"><span face="Verdana" style="line-height: 1.5; font-family: Verdana;"></span></span>

二、原理简介
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>
<span class="Apple-style-span" style="font-family: 宋体, Arial; line-height: 18px; white-space: normal; font-size: 12px;"><span face="Verdana" style="line-height: 1.5; font-family: Verdana;"><br>参考:<br>1、<a href="http://blog.chinaunix.net/link.php?url=http://www.castaglia.org%2Fproftpd%2Fdoc%2Fcontrib%2FProFTPD-mini-HOWTO-Limit.html" style="text-decoration: none; color: #63401b;"></a><a href="http://blog.chinaunix.net/link.php?url=http://www.castaglia.org%2Fproftpd%2Fdoc%2Fcontrib%2FProFTPD-mini-HOWTO-Limit.html" target="_blank" style="text-decoration: none; color: #63401b;"><span color="#0000ff" style="line-height: 1.5; color: #0000ff;">http://www.castaglia.org/proftpd/doc/contrib/ProFTPD-mini-HOWTO-Limit.html</span></a><br>2、<a href="http://blog.chinaunix.net/link.php?url=http://www.castaglia.org%2Fproftpd%2F" style="text-decoration: none; color: #63401b;"></a><a href="http://blog.chinaunix.net/link.php?url=http://www.castaglia.org%2Fproftpd%2F" target="_blank" style="text-decoration: none; color: #63401b;"><span color="#0000ff" style="line-height: 1.5; color: #0000ff;">http://www.castaglia.org/proftpd/</span></a><br>3、<a href="http://blog.chinaunix.net/link.php?url=http://www.proftpd.org%2F" style="text-decoration: none; color: #63401b;"></a><a href="http://blog.chinaunix.net/link.php?url=http://www.proftpd.org%2F" target="_blank" style="text-decoration: none; color: #63401b;"><span color="#0000ff" style="line-height: 1.5; color: #0000ff;">http://www.proftpd.org/</span></a></span></span>

本文出自 “GONE WITH THE WIND” 博客,请务必保留此出处http://h2appy.blog.51cto.com/609721/123997

 

----博主补充错误解决!

1, IPV6 出错:

How to I completely disable (or remove) IPv6 from my slackware box? I'm using 10.1 atm.

在/etc/modprobe.conf 加上 alias net-pf-10 off

2,proftpd不能正常啟動 Starting proftpd: localhost.localdomain - error converting stdin to IPv6 socket: Socket operation on non-socket 
localhost.localdomain - fatal: Socket operation on non-socket

解决: 設成 inetd, 那麼 proftpd 就是由 inetd/xinetd 啟動. 
若要手動執行 proftpd, 要把 ServerType 設成 standalone 才行.

 
#################################
#能实现ip访问控制
#能实现目录的ip访问控制
#能实现多虚拟机
#能与mysql联合控制用户访问
#能实现防Dos攻击等安全机制
######################################################################
#范例一:Basic
#范例二:Anonymous
#范例三:Virtual hosts
#范例四:Complex Virtual
#范例五:Simple MySQL Authentication
########################范例一#########################################
# This sample configuration file illustrates configuring two
# anonymous directories, and a guest (same thing as anonymous but
# requires a valid password to login)
 
ServerName "ProFTPD Anonymous Server"
ServerType standalone
 
# Port 21 is the standard FTP port.
Port 21
 
# If you don't want normal users logging in at all, uncomment this
# next section
#<Limit LOGIN>
# DenyAll
#</Limit>
 
# Set the user and group that the server normally runs at.
User nobody
Group nogroup
 
# 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 maximum number of seconds a data connection is allowed
# to "stall" before being aborted.
TimeoutStalled 300
 
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayFirstChdir .message
 
# Our "basic" anonymous configuration, including a single
# upload directory ("uploads")
<Anonymous ~ftp>
 
# Allow logins if they are disabled above.
<Limit LOGIN>
AllowAll
</Limit>
 
# Maximum clients with message
MaxClients 5 "Sorry, max %m users -- try again later"
 
User ftp
Group ftp
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
 
# Limit WRITE everywhere in the anonymous chroot
<Limit WRITE>
DenyAll
</Limit>
 
# An upload directory that allows storing files but not retrieving
# or creating directories.
<Directory uploads/*>
<Limit READ>
DenyAll
</Limit>
 
<Limit STOR>
AllowAll
</Limit>
</Directory>
</Anonymous>
 
# A second anonymous ftp section. Users can login as "private". Here
# we hide files owned by root from being manipulated in any way.
 
<Anonymous /usr/local/private>
User bobf
Group users
UserAlias private bobf
UserAlias engineering bobf
 
# Deny access from *.evil.net and *.otherevil.net, but allow
# all others.
<Limit LOGIN>
Order deny,allow
Deny from .evil.net, .otherevil.net
Allow from all
</Limit>
 
# We want all uploaded files to be owned by 'engdept' group and
# group writable.
GroupOwner engdept
Umask 006
 
# Hide all files owned by user 'root'
HideUser root
 
<Limit WRITE>
DenyAll
</Limit>
 
# Disallow clients from any access to hidden files.
<Limit READ DIRS>
IgnoreHidden on
</Limit>
 
# Permit uploading and creation of new directories in
# submissions/public
 
<Directory submissions/public>
<Limit READ>
DenyAll
IgnoreHidden on
</Limit>
 
<Limit STOR MKD RMD XMKD XRMD>
AllowAll
IgnoreHidden on
</Limit>
</Directory>
</Anonymous>
 
# The last anonymous example creates a "guest" account, which clients
# can authenticate to only if they know the user's password.
 
<Anonymous ~guest>
User guest
Group nobody
AnonRequirePassword on
 
<Limit LOGIN>
AllowAll
</Limit>
 
# Deny write access from all except trusted hosts.
<Limit WRITE>
Order allow, deny
Allow from 10.0.0.
Deny from all
</Limit>
</Anonymous>
########################范例二#########################################
# This sample configuration file illustrates creating two
# virtual servers, and associated anonymous logins.
 
ServerName "ProFTPD"
ServerType inetd
 
# Port 21 is the standard FTP port.
Port 21
 
# Global creates a "global" configuration that is shared by the
# main server and all virtualhosts.
 
<Global>
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
</Global>
 
# Set the user and group that the server normally runs at.
User nobody
Group nogroup
 
# 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
 
# Maximum seconds a data connection may "stall"
TimeoutStalled 300
 
# First virtual server
<VirtualHost ftp.virtual.com>
ServerName "Virtual.com's FTP Server"
 
MaxClients 10
MaxLoginAttempts 1
 
# DeferWelcome prevents proftpd from displaying the servername
# until a client has authenticated.
DeferWelcome on
 
# Limit normal user logins, because we only want to allow
# guest logins.
<Limit LOGIN>
DenyAll
</Limit>
 
# Next, create a "guest" account (which could be used
# by a customer to allow private access to their web site, etc)
<Anonymous ~cust1>
User cust1
Group cust1
AnonRequirePassword on
 
<Limit LOGIN>
AllowAll
</Limit>
 
HideUser root
HideGroup root
 
# A private directory that we don't want the user getting in to.
<Directory logs>
<Limit READ WRITE DIRS>
DenyAll
</Limit>
</Directory>
</Anonymous>
</VirtualHost>
########################范例三#########################################
# Another virtual server, this one running on our primary address,
# but on port 4000. The only access is to a single anonymous login.
<VirtualHost our.ip.address>
ServerName "Our private FTP server"
Port 4000
Umask 027
 
<Limit LOGIN>
DenyAll
</Limit>
 
<Anonymous /usr/local/ftp/virtual/a_customer>
User ftp
Group ftp
UserAlias anonymous ftp
 
<Limit LOGIN>
AllowAll
</Limit>
 
<Limit WRITE>
DenyAll
</Limit>
 
<Directory incoming>
<Limit WRITE>
AllowAll
</Limit>
</Directory>
</Anonymous>
</VirtualHost>
 
#
# Virtual Hosting Server Configuration
# by M.Lowes <markl@ftech.net>
# for Frontier Internet Services Limited
# (http://www.ftech.net/)
#
ServerName "Master Webserver"
#
# Spawn from inetd?
#
#ServerType inetd
#
# or maybe a standalone server...
#
ServerType standalone
#
# don't give the server banner until _after_ authentication
#
DeferWelcome off
#
# Some basic defaults
#
Port 21
Umask 002
TimeoutLogin 120
TimeoutIdle 600
TimeoutNoTransfer 900
TimeoutStalled 3600
#
# No, I don't think we'll run as root!
#
User ftp
Group ftp
#
# This is a non-customer usable name, (ie they should be connecting via www.{domain})
# not 'hostname'. Therefore let's dump them in a dummy account and wait for them to
# scream.
#
DefaultRoot /web/Legacy/
#
# Performance, let's do DNS resolution when we process the logs...
#
UseReverseDNS off
#
# Where do we put the pid files?
#
ScoreboardPath /var/run/proftpd
#
# Logging options
#
TransferLog /var/spool/syslog/proftpd/xferlog.legacy
#
# Some logging formats
#
LogFormat default "%h %l %u %t \"%r\" %s %b"
LogFormat auth "%v [%P] %h %t \"%r\" %s"
LogFormat write "%h %l %u %t \"%r\" %s %b"
#
# Global settings
#
<Global>
DisplayLogin welcome.msg
DisplayFirstChdir readme
#
# having to delete before uploading is a pain 
#
AllowOverwrite yes
#
# Turn off Ident lookups
#
IdentLookups off
#
# Logging
#
# file/dir access
#
ExtendedLog /var/spool/syslog/proftpd/access.log WRITE,READ write
#
#
# Record all logins
#
ExtendedLog /var/spool/syslog/proftpd/auth.log AUTH auth
#
# Paranoia logging level....
#
##ExtendedLog /var/spool/syslog/proftpd/paranoid.log ALL default
</Global>
 
#
# Deny writing to the base server...
#
<Limit WRITE>
DenyAll
</Limit>
 
 
# --------------------------------------------
# Virtual Servers start here....
#
# (Note: this is normally auto generated by a
# script written in house).
# --------------------------------------------
#
# www.ftech.net.
# This is the default server
# Gets all the connections for www.{customer.domain},
# & www.ftech.net
#
<VirtualHost www.ftech.net>
ServerAdmin webmaster@Ftech.net
ServerName "Master Webserver"
MaxLoginAttempts 2
RequireValidShell no
TransferLog /var/spool/syslog/proftpd/xferlog.www
MaxClients 50
DefaultServer on
DefaultRoot ~ !staff
AllowOverwrite yes
 
#
# No quickly do we kick someone out
#
TimeoutLogin 120
TimeoutIdle 600
TimeoutNoTransfer 900
 
# --------------------------------------------
# Got a Frontpage customer who keeps breaking things????
# - stick 'em in group fpage
# --------------------------------------------
<Directory ~/public_html>
#
# Block them from doing anything other than reading...
#
<Limit STOR RNFR DELE>
DenyGroup fpage
</Limit>
</Directory>
#
# ditto for ftp_root if it's there...
#
<Directory ~/ftp_root>
<Limit STOR RNFR DELE>
DenyALL
</Limit>
</Directory>
#
# Limit by IP...
#
<Directory /web/zsl>
<Limit ALL>
Order Allow,Deny
Allow 195.200.31.220
Allow 212.32.17.0/26
Deny ALL
</Limit>
</Directory>
 
</VirtualHost>
 
# --------------------------------------------
#
# Legacy server, left in because some people
# haven't realised it's gone yet. Shove 'em into
# a dummy $home
#
<VirtualHost web-1.ftech.net>
ServerAdmin webmaster@Ftech.net
ServerName "Legacy Web Upload Server"
MaxLoginAttempts 2
RequireValidShell no
MaxClients 50
DefaultRoot ~ !staff
MaxClients 2
AllowOverwrite yes
TransferLog /var/spool/syslog/proftpd/xferlog.web-1
</VirtualHost>
 
# --------------------------------------------
#
# ftp.ftech.net
#
<VirtualHost ftp.ftech.net>
ServerAdmin ftpmaster@ftech.net
ServerName "Frontier Internet Public FTP Server"
TransferLog /ftp/xferlog/ftp.ftech.net
MaxLoginAttempts 3
RequireValidShell no
DefaultRoot /ftp/ftp.ftech.net
AllowOverwrite yes
 
#
#
########################范例四#########################################
#
# Virtual Hosting Server Configuration
# by M.Lowes <markl@ftech.net>
# for Frontier Internet Services Limited
# (http://www.ftech.net/)
#
ServerName "Master Webserver"
#
# Spawn from inetd?
#
#ServerType inetd
#
# or maybe a standalone server...
#
ServerType standalone
#
# don't give the server banner until _after_ authentication
#
DeferWelcome off
#
# Some basic defaults
#
Port 21
Umask 002
TimeoutLogin 120
TimeoutIdle 600
TimeoutNoTransfer 900
TimeoutStalled 3600
#
# No, I don't think we'll run as root!
#
User ftp
Group ftp
#
# This is a non-customer usable name, (ie they should be connecting via www.{domain})
# not 'hostname'. Therefore let's dump them in a dummy account and wait for them to
# scream.
#
DefaultRoot /web/Legacy/
#
# Performance, let's do DNS resolution when we process the logs...
#
UseReverseDNS off
#
# Where do we put the pid files?
#
ScoreboardPath /var/run/proftpd
#
# Logging options
#
TransferLog /var/spool/syslog/proftpd/xferlog.legacy
#
# Some logging formats
#
LogFormat default "%h %l %u %t \"%r\" %s %b"
LogFormat auth "%v [%P] %h %t \"%r\" %s"
LogFormat write "%h %l %u %t \"%r\" %s %b"
#
# Global settings
#
<Global>
DisplayLogin welcome.msg
DisplayFirstChdir readme
#
# having to delete before uploading is a pain 
#
AllowOverwrite yes
#
# Turn off Ident lookups
#
IdentLookups off
#
# Logging
#
# file/dir access
#
ExtendedLog /var/spool/syslog/proftpd/access.log WRITE,READ write
#
#
# Record all logins
#
ExtendedLog /var/spool/syslog/proftpd/auth.log AUTH auth
#
# Paranoia logging level....
#
##ExtendedLog /var/spool/syslog/proftpd/paranoid.log ALL default
</Global>
 
#
# Deny writing to the base server...
#
<Limit WRITE>
DenyAll
</Limit>
 
 
# --------------------------------------------
# Virtual Servers start here....
#
# (Note: this is normally auto generated by a
# script written in house).
# --------------------------------------------
#
# www.ftech.net.
# This is the default server
# Gets all the connections for www.{customer.domain},
# & www.ftech.net
#
<VirtualHost www.ftech.net>
ServerAdmin webmaster@Ftech.net
ServerName "Master Webserver"
MaxLoginAttempts 2
RequireValidShell no
TransferLog /var/spool/syslog/proftpd/xferlog.www
MaxClients 50
DefaultServer on
DefaultRoot ~ !staff
AllowOverwrite yes
 
#
# No quickly do we kick someone out
#
TimeoutLogin 120
TimeoutIdle 600
TimeoutNoTransfer 900
 
# --------------------------------------------
# Got a Frontpage customer who keeps breaking things????
# - stick 'em in group fpage
# --------------------------------------------
<Directory ~/public_html>
#
# Block them from doing anything other than reading...
#
<Limit STOR RNFR DELE>
DenyGroup fpage
</Limit>
</Directory>
#
# ditto for ftp_root if it's there...
#
<Directory ~/ftp_root>
<Limit STOR RNFR DELE>
DenyALL
</Limit>
</Directory>
#
# Limit by IP...
#
<Directory /web/zsl>
<Limit ALL>
Order Allow,Deny
Allow 195.200.31.220
Allow 212.32.17.0/26
Deny ALL
</Limit>
</Directory>
 
</VirtualHost>
 
# --------------------------------------------
#
# Legacy server, left in because some people
# haven't realised it's gone yet. Shove 'em into
# a dummy $home
#
<VirtualHost web-1.ftech.net>
ServerAdmin webmaster@Ftech.net
ServerName "Legacy Web Upload Server"
MaxLoginAttempts 2
RequireValidShell no
MaxClients 50
DefaultRoot ~ !staff
MaxClients 2
AllowOverwrite yes
TransferLog /var/spool/syslog/proftpd/xferlog.web-1
</VirtualHost>
 
# --------------------------------------------
#
# ftp.ftech.net
#
<VirtualHost ftp.ftech.net>
ServerAdmin ftpmaster@ftech.net
ServerName "Frontier Internet Public FTP Server"
TransferLog /ftp/xferlog/ftp.ftech.net
MaxLoginAttempts 3
RequireValidShell no
DefaultRoot /ftp/ftp.ftech.net
AllowOverwrite yes
 
#
# Auth files....
#
AuthUserFile /var/conf/ftp/authfiles/passwd.ftp.ftech.net
AuthGroupFile /var/conf/ftp/authfiles/group.ftp.ftech.net
 
# A basic anonymous configuration, no upload directories.
<Anonymous /ftp/ftp.ftech.net>
User ftp
Group ftp
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
RequireValidShell no
 
# Limit the maximum number of anonymous logins
MaxClients 50
 
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
 
<Directory pub/incoming>
<Limit STOR>
AllowAll
</Limit>
<Limit WRITE DIRS READ>
DenyAll
</Limit>
<Limit CWD XCWD CDUP>
AllowAll
</Limit>
</Directory>
 
<Directory home>
<Limit ALL>
DenyAll
</Limit>
</Directory>
 
#
# Limit access to the mirrors to LINX
# only
#
<Directory mirrors>
<Limit RETR>
Order Allow,Deny
Allow .uk, .ftech.net
Allow .vom.tm
Deny ALL
</Limit>
</Directory>
 
# Limit WRITE everywhere in the anonymous chroot
<Limit WRITE>
DenyAll
</Limit>
 
 
</Anonymous>
 
</VirtualHost>
 
# ----------------------------------------------------
# Virtual ftp with anon access, but no incoming
#
<VirtualHost ftp.foo1.com>
ServerAdmin ftpmaster@foo1.com
ServerName "Foo1 FTP Server"
TransferLog /var/spool/syslog/xfer/ftp.foo1.com
MaxLoginAttempts 3
RequireValidShell no
DefaultRoot /ftp/ftp.foo1.com
User foo1
Group foo1
AllowOverwrite yes
 
#
# Auth files....
#
AuthUserFile /var/conf/ftp//authfiles/passwd.ftp.foo1.com
AuthGroupFile /var/conf/ftp//authfiles/group.ftp.foo1.com
 
<Anonymous /ftp/ftp.foo1.com>
User ftp
Group ftp
UserAlias anonymous ftp
RequireValidShell no
MaxClients 20
<Limit WRITE>
DenyAll
</Limit>
</Anonymous>
</VirtualHost>
 
 
# ----------------------------------------------------
# ftp.foo2.com
# Anon, no incoming, some private access areas
#
<VirtualHost ftp.foo2.com>
ServerAdmin ftpmaster@mcresearch.co.uk
ServerName "MC Research FTP Server"
TransferLog /var/spool/syslog/xfer/ftp.foo2.com
MaxLoginAttempts 3
RequireValidShell no
DefaultRoot /ftp/ftp.foo2.com
User foo2
Group foo2
AllowOverwrite yes
 
#
# Auth files....
#
AuthUserFile /var/conf/ftp//authfiles/passwd.ftp.foo2.com
AuthGroupFile /var/conf/ftp//authfiles/group.ftp.foo2.com
 
<Anonymous /ftp/ftp.foo2.com>
User ftp
Group ftp
UserAlias anonymous ftp
RequireValidShell no
MaxClients 20
 
<Directory download>
<Limit ALL>
DenyAll
</Limit>
</Directory>
<Limit WRITE>
DenyAll
</Limit>
</Anonymous>
 
<Directory /ftp/ftp.foo2.com/pub>
<Limit WRITE>
AllowUser mcres
DenyAll
</Limit>
</Directory>
 
<Directory /ftp/ftp.foo2.com/download>
<Limit ALL>
AllowUser mcres
AllowUser customer
DenyAll
</Limit>
</Directory>
</VirtualHost>
 
 
# ----------------------------------------------------
# ftp.foo3.com
#
#
<VirtualHost ftp.foo3.com>
ServerAdmin ftpmaster@farrukh.co.uk
ServerName "Farrukh FTP Archive"
TransferLog /var/spool/syslog/xfer/ftp.foo3.com
MaxLoginAttempts 3
RequireValidShell no
DefaultRoot /web/farrukh2/ftp_root
User farrukh2
Group farrukh2
AllowOverwrite yes
 
#
# Auth files....
#
AuthUserFile /var/conf/ftp//authfiles/passwd.ftp.foo3.com
AuthGroupFile /var/conf/ftp//authfiles/group.ftp.foo3.com
 
<Anonymous /web/farrukh2/ftp_root>
User ftp
Group ftp
UserAlias anonymous ftp
RequireValidShell no
MaxClients 20
 
<Directory pub/incoming/*>
<Limit STOR>
AllowAll
</Limit>
<Limit WRITE DIRS READ>
DenyAll
</Limit>
<Limit CWD XCWD CDUP>
AllowAll
</Limit>
</Directory>
 
 
<Directory pub/Incoming/*>
<Limit STOR>
AllowAll
</Limit>
<Limit WRITE DIRS READ>
DenyAll
</Limit>
<Limit CWD XCWD CDUP>
AllowAll
</Limit>
</Directory>
#
# block access to the secure areas by anon...
#
<Directory fpub>
<Limit ALL>
DenyAll
</Limit>
</Directory>
 
<Directory fgroup>
<Limit ALL>
DenyAll
</Limit>
</Directory>
<Limit WRITE>
DenyAll
</Limit>
</Anonymous>
 
#
# define user based access
#
<Directory /web/farrukh2/ftp_root/fpub>
<Limit ALL>
AllowUser farrukh
AllowUser fguest
DenyAll
</Limit>
</Directory>
 
<Directory /web/farrukh2/ftp_root/fgroup>
<Limit ALL>
AllowUser farrukh
AllowUser fgroup
DenyAll
</Limit>
</Directory>
</VirtualHost>
 
 
# ----------------------------------------------------
# ftp.foo4.com
# anon, with incoming upload
#
<VirtualHost ftp.foo4.com>
ServerAdmin ftpmaster@teamwork.co.uk
ServerName "Teamwork FTP Server"
TransferLog /var/spool/syslog/xfer/ftp.foo4.com
MaxLoginAttempts 3
RequireValidShell no
DefaultRoot /ftp/ftp.foo4.com
User foo4
Group foo4
AllowOverwrite yes
 
#
# Auth files....
#
AuthUserFile /var/conf/ftp//authfiles/passwd.ftp.foo4.com
AuthGroupFile /var/conf/ftp//authfiles/group.ftp.foo4.com
 
<Anonymous /ftp/ftp.foo4.com>
User ftp
Group ftp
UserAlias anonymous ftp
RequireValidShell no
MaxClients 20
 
<Directory pub/incoming/*>
<Limit STOR>
AllowAll
</Limit>
<Limit WRITE DIRS READ>
DenyAll
</Limit>
<Limit CWD XCWD CDUP>
AllowAll
</Limit>
</Directory>
 
 
<Directory pub/Incoming/*>
<Limit STOR>
AllowAll
</Limit>
<Limit WRITE DIRS READ>
DenyAll
</Limit>
<Limit CWD XCWD CDUP>
AllowAll
</Limit>
</Directory>
 
<Limit WRITE>
DenyAll
</Limit>
</Anonymous>
</VirtualHost>
 
# ----------------------------------------------------
# The end....
# ----------------------------------------------------
########################范例五#########################################
##
## Config with simple mysql authentication support
## Contributed by 'Stonki'
## Added to www.proftpd.org 18/Oct/2002
##
 
# This is a basic ProFTPD configuration file. It establishes a single
# server and a single anonymous login. It assumes that you have a
# user/group "nobody"/"nogroup" for normal operation and anon.
 
# !!! PLEASE read the documentation of proftpd !!!
#
# You can find the documentation in /usr/doc/packages/proftpd/,
# http://www.proftpd.org/ and don't forget to read carefully
# and _follow_ hints on http://www.proftpd.net/security.html.
 
 
#
# geaendert: 03.11.2001 für ProFTP 1.2.4 und mod_sql 4.x
#
 
#
# Basic
#
ServerName "Stonki"
serverType inetd
ServerAdmin support@stonki.de
 
#
# Debug Level
# emerg, alert, crit (empfohlen), error, warn. notice, info, debug
#
#SyslogLevel emerg
#SystemLog /var/log/proftpd.system.log
 
#
# uncomment, if you want to hide the servers name:
#
ServerIdent on "Stonki's Server"
DeferWelcome on
DefaultServer on
 
#
# Display
#
DisplayLogin /messages/ftp.motd
DisplayConnect /net/messages/ftp.pre
DisplayFirstChdir index.txt
 
HiddenStor off
DirFakeUser on stonki
DirFakeGroup on stonki
DirFakeMode 0000
 
 
 
# Enable PAM for authentication...
#
AuthPAM on
 
# Setting this directive to on will cause authentication to fail
# if PAM authentication fails. The default setting, off, allows
# other modules and directives such as AuthUserFile and friends
# to authenticate users.
#
# AuthPAMAuthoritative on
 
# This directive allows you to specify the PAM service name used
# in authentication (default is "proftpd" on SuSE Linux).
# You have to setup the service in the /etc/pam.d/<other_name>.
#
#AuthPAMConfig <other_name>
 
# Port 21 is the standard FTP port.
Port 21
 
#------------------------mysql Modul: 4.x
#
# Zugangskontrolle
#
SQLAuthTypes Plaintext
SQLAuthenticate users*
SQLConnectInfo db@localhost uname password
SQLDefaultGID 65534
SQLDefaultUID 65534
SQLMinUserGID 100
SQLMinUserUID 500
SQLUserInfo ftp uname password uid gid homedir shell
 
#
# aktive SQL Kommandos, ab hier passiert etwas 
#
SQLLog PASS counter
SQLNamedQuery counter UPDATE "letzter_zugriff=now(), count=count+1 WHERE uname='%u'" ftp
 
# xfer Log in mysql
SQLLog RETR,STOR transfer1
SQLNamedQuery transfer1 INSERT "'%u', '%f', '%b', '%h', '%a', '%m', '%T', now(), 'c', NULL" xfer_stat
 
SQLLOG ERR_RETR,ERR_STOR transfer2
SQLNamedQuery transfer2 INSERT "'%u', '%f', '%b', '%h', '%a', '%m', '%T', now(), 'i', NULL" xfer_stat
 
#------------------------mysql
 
# Port 21 is the standard FTP port.
Port 21
 
# disable listen on 0.0.0.0:21 - the port (and IP) should
# be specified explicitly in each VirtualHost definition
#
#Port 0
 
# listen for each (additional) address explicitly that is
# specified (via Bind and Port) in a VirtualHost definition
#
#SocketBindTight on
 
#
# FXP Unterstuetzung
#
AllowForeignAddress on
 
 
# Umask 022 is a good standard umask to prevent new dirs
# and files from being group and world writable.
Umask 022
 
# Set the user and group that the server normally runs at.
User nobody
Group nogroup
 
# Maximal Werte setzen
MaxClientsPerHost 3 "Nicht mehr als %m Verbindungen"
MaxClients 5 "Leider sind schon %m Clients verbunden"
 
# RateReadBPS 5000
# RateReadFreeBytes 5000
# RateReadHardBPS on
 
Classes on
Class default limit 5
Class internet limit 2
Class local limit 3
Class internet ip 0.0.0.0/0
Class internet ip 192.168.99.99/24
Class local ip 127.0.0.1/24
Class local ip 192.168.0.0/24
 
#
# Restart erlauben
#
AllowStoreRestart on
AllowRetrieveRestart on
 
# Normally, we want files to be overwriteable.
<Directory /*>
AllowOverwrite off
HideNoAccess on
<Limit READ>
AllowAll
</Limit>
<Limit Write>
DenyAll
</Limit>
</Directory>
 
<Directory /net/incoming/*> 
//范例5貌似不全



(责任编辑:IT)
------分隔线----------------------------