proftp1.3.x配置

与1.2.x的相比,1.3似乎配置文件上有点差别,我马上又抄了一份过来

转自:http://www.itbkb.cn/article.asp?id=79

一、软件下载

proftpd-1.3.2b.tar.gz

官方网站:http://www.proftpd.org/

镜像站点:http://www.proftpd.de/

[root@localhost ]# wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.2b.tar.gz

二、解压缩、编译安装

# 解压缩

[root@localhost ]# tar zvxf proftpd-1.3.2b.tar.gz

[root@localhost ]#cd proftpd-1.3.2b

#编译安装(安装到/usr/local/proftpd目录下,可随意改变此目录)

[root@localhost proftpd-1.3.2b]# ./configure --prefix=/usr/local/proftpd

[root@localhost proftpd-1.3.2b]# make

[root@localhost proftpd-1.3.2b]# make install

 

三、建立FTP用户及相关权限(此处可根据实际需要配置)

1、建立用户组及用户

[root@localhost ]# groupadd ftpusers # 增加一个ftpusers

[root@localhost ]# userdel -rf softsoul

[root@localhost ]# useradd -d /tools -g ftpusers -s /sbin/nologin softsoul

# ftpusers组增加一个名为softsoul的用户,目录设定为/tools,软件上传专用。注意:如果不加参数-d /tools,则默认在/home下建立用户名目录,如:/home/softsoul

[root@localhost ]# passwd softsoul #设置用户的口令。

 

[root@localhost ]# userdel -rf websoul

[root@localhost ]# useradd -d /data0/htdocs/www -g ftpusers -s /sbin/nologin websoul

# ftpusers组增加一个名为websoul的用户,目录设定为/data0/htdocs/www,WEB server专用

[root@localhost ]# passwd websoul #设置用户的口令。

2、建立上传目录

[root@localhost ]# mkdir /tools #在根目录下建立tools目录,作为软件上传目录。

[root@localhost /]# chgrp -R ftpusers /tools  # tools的归属组也改为 ftpusers

[root@localhost ]# chmod -R 775 /tools  # 设置ftpusers组对该文件夹具有读写执行的权限,其他用户只有读、执行权限。

 

# 如果你已经配置好WEB server/data0/htdocs/www目录已经存在,只需如下修改目录权限(也可以在GUI界面下操作)

[root@localhost ]# chgrp -R ftpusers /data0/htdocs/www  # wwwroot的归属组改为 ftpusers 组。

[root@localhost ]# chmod -R 777 /data0/htdocs/www # 设置权限,ftpusers组对该文件夹具有读写执行的权限,其他用户只有读、写、执行权限(不可没有执行权限,否则web浏览不了)。

[root@localhost ]# chown -R websoul:ftpusers /data0/htdocs/www

 

三、FTP server配置

 # 如果是和偶一样的菜鸟,建议在GUI界面下用gedit打开/usr/local/proftpd/etc/proftpd.conf进行配置,配置之前建议做好备份

[root@localhost ]#cp /usr/local/proftpd/etc/proftpd.conf /usr/local/proftpd/etc/proftpd.conf.save

[root@localhost ]# vi /usr/local/proftpd/etc/proftpd.conf

# 以下是偶的proftpd.conf配置内容

XML/HTML代码
  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   
  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   
  27. # 最多有30个proftpd的PID   
  28.   
  29. #MaxHostsPerUser 3 "Sorry, you may not connect more than one time"   
  30. # 每个IP只允许三个连接   
  31.   
  32. #MaxClientsPerUser 3 "Only one such user at a time"   
  33. # 每个帐户在每个客户端最多可以同时登陆3次   
  34.   
  35. #MaxClientsPerHost 3 "Sorry, you may not connect more than one time"   
  36. # 同一个客户端只能最多3个帐号可以登陆   
  37.   
  38.   
  39. # Set the user and group under which the server will run.   
  40. User                            nobody   
  41. Group                           nobody   
  42.   
  43. # To cause every FTP user to be "jailed" (chrooted) into their home   
  44. # directory, uncomment this line.   
  45. DefaultRoot ~ ftpusers   
  46. #注意~和ftpusers中间有空格。   
  47.   
  48. # Normally, we want files to be overwriteable.   
  49. AllowOverwrite          on   
  50.   
  51. # Bar use of SITE CHMOD by default   
  52. <Limit SITE_CHMOD>  
  53.   DenyAll   
  54. </Limit>  
  55.   
  56. <Limit LOGIN>  
  57. DenyALL   
  58. AllowGroup ftpusers   
  59. </Limit>  
  60. # 设置只有ftpusers组的用户可以ftp登录   
  61.   
  62. <Directory /data0/htdocs/www>  
  63. <Limit ALL>  
  64. AllowUser websoul   
  65. </Limit>  
  66. </Directory>  
  67. # 设置帐号websoul拥有/data0/htdocs/www目录的所有权限   
  68.   
  69. <Directory /tools>  
  70. <Limit ALL>  
  71. AllowUser softsoul   
  72. </Limit>  
  73. </Directory>  
  74. # 设置帐号softsoul拥有/tools目录的所有权限   
  75.   
  76. # Limit the maximum number of anonymous logins   
  77.   MaxClients            10   
  78. # 最多允许10个用户在线   
  79. # We want 'welcome.msg' displayed at login, and '.message' displayed   
  80. # in each newly chdired directory.   
  81. #DisplayLogin            welcome.msg   
  82. # 当使用者登录时,则会显示 welcome.msg 中的欢迎词信息   
  83. #DisplayFirstChdir        .message   
  84. # 当使用者转换目录,则会显示 .message 中的信息   
  85. ##(上面的欢迎信息我测试后好象不成功,郁闷中,,,,,)   
  86. ServerIdent off # 屏蔽服务器版本信息   
  87. MaxLoginAttempts 6 # 最大连接次数   
  88. WtmpLog on # 是否要把ftp记录在日志中,如果不想可以设置成off屏蔽掉log日志。   
  89. TimeoutIdle 600 # 客户端idel时间设置,默认就是600秒   
  90. AllowRetrieveRestart on # 下载时,允许断点续传(默认已有,可不设置)   
  91. AllowStoreRestart on # 上传时,允许断点续传   
  92. AllowForeignAddress on   
  93. # 让proftp支持现在流行的FXP传输方式,默认是不支持的。   
  94. PassivePorts 48888 65534 # 端口也可自己指定喜欢的   
  95.   
  96.   
  97. # A basic anonymous configuration, no upload directories.  If you do not   
  98. # want anonymous users, simply delete this entire <Anonymous> section.   
  99. <Anonymous ~ftp>  
  100.   User                          ftp   
  101.   Group                         ftp   
  102.   
  103.   # We want clients to be able to login with "anonymous" as well as "ftp"   
  104.   UserAlias                     anonymous ftp   
  105.   
  106.   # Limit the maximum number of anonymous logins   
  107.   MaxClients                    10   
  108.   
  109.   # We want 'welcome.msg' displayed at login, and '.message' displayed   
  110.   # in each newly chdired directory.   
  111.   DisplayLogin                  welcome.msg   
  112.   DisplayChdir                  .message   
  113.   
  114.   # Limit WRITE everywhere in the anonymous chroot   
  115.   <Limit WRITE>  
  116.     DenyAll   
  117.   </Limit>  
  118. </Anonymous>  

四、开机自动运行proftpd

 

# 通过如下命令启动proftpd

[root@ftpd /]# /etc/rc.d/init.d/proftpd start

 

 # 若需要将proftpd设置为系统启动时自动启动则通过如下命令拷贝启动文件:

[root@proftpd-1.3.2b]# cp ./contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd

 # 修改该脚本的可执行属性:

[root@localhost /]# chmod +x /etc/rc.d/init.d/proftpd

**********看网上有的文章为以下内容,大家可以参考****************************

然后编辑/etc/rc.d/init.d/functions

修改

export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"

export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin"

注:若将在运行./cofigure命令时通过--prefix选项指定将proftpd安装在/usr/sbin目录下则不需要修改fuctions文件。

***************************************************************************

这段内容是我根据自己的实际情况修改的内容,与上面一段二者选一,大家试一下吧

编辑/etc/rc.d/init.d/proftpd

 修改

PATH="$PATH:/usr/local/sbin"

PATH="$PATH:/usr/local/proftpd/sbin"

======================================================

 # 然后运行命令:

[root@localhost /]# chkconfig --level 35 proftpd on

 # 则下次系统启动以后,proftpd将自动启动。

 

 # 通过如下命令启动proftpd

[root@ftpd /]# /etc/rc.d/init.d/proftpd start

 

这时候可以通过如下命令来测试proftpd是否正常运行:

[root@homeserver usr]# ftp 192.168.1.20

Connected to 192.168.1.20.

220 192.168.1.20 FTP server ready

500 AUTH not understood

500 AUTH not understood

KERBEROS_V4 rejected as an authentication type

Name (192.168.1.20:phoebus): softsoul

331 Password required for softsoul.

Password:

230 User softsoul logged in.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp>

 

我们用查看一下有没有ftp进程

# ps -ax|grep ftp

如果出现类似下面,表示已经启动啦!

 4441 ?        S      0:00 [proftpd]

 

这里要讲一个非常实用的命令,

/usr/local/proftpd/sbin/ftpshut

这个命令还是比较实用的,因为你可能需要不断的调整你的服务器,而这个命令就非常灵活,可以在不停止proftpd进程的前提下,定时停止ftp连接,这里将会详细说它是怎么使用的。

 

ftpshut [ -l min ] [ -d min ] time [ warning-message ... ]

 

-l min: ftp关闭服务之前的几分钟内,尝试建立新的ftp连接均不被接受

-d min: ftp关闭服务之前的几分钟内,已经建立的ftp连接将被中止

time: 在多少时间后,服务器将关闭ftp服务,格式有两种

number 经过number分钟后关闭

MMHH 在今天MMHH服务器将关闭

注意,这里我们用这个命令是把ftp服务给停了,但实际的proftpd进程还没停止,所以一般调试ftp会使用到这个命令。

举例:

再经过30分钟后,FTP服务将关闭,在这之前的20分钟不可接受任何新的ftp连接,已经建立的在服务关闭前10分钟强制断线,并在客户端显示“FTP Server Will shutdown at time”

 

ftpshut -l 20 -d 10 +30 "FTP Server Will shutdown at time"

其实ftpshut就是产生/etc/shutmsg ,你只要删除这个文件ftp又可以重新服务,或者

直接ftpshut -R

好了,开始讲一些proftpd的基本配置吧,其实大家如果熟悉apache的配置的话,你会发现proftpd的设置基本都是类似的,它的配置基本格式是

#全局设置

设置项目1 参数1

设置项目2 参数2

#某个目录的设置

<Directory "路径名">

...

...

</Directory>

#关于匿名用户的设置

<Anonymous "匿名登陆的目录">

...

...

<Limit 限制动作>

...

...

</Limit>

</Anonymous>

 

我们用到的比较多的可能是Limit的使用,Limit大致有以下动作,基本能覆盖全部的权限了,大家灵活使用就是了。

CMDChange Working Directory 改变目录

MKDMaKe Directory 建立目录的权限

RNFR ReName FRom 更改目录名的权限

DELEDelete 删除文件的权限

RMDReMove Directory 删除目录的权限

RETRRETRieve 从服务端下载到客户端的权限

STORSTORe 从客户端上传到服务端的权限

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

WRITE:写文件或者目录的权限,包括MKDRMD

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

ALL:所有权限

LOGIN:是否允许登陆的权限

针对上面这个Limit所应用的对象,又包括以下范围

AllowUser 针对某个用户允许的Limit

DenyUser 针对某个用户禁止的Limit

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

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

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

DenyAll 针对所有用户禁止的Limit

关于限制速率的参数为:

TransferRate STOR|RETR 速度(Kbytes/s user 使用者

下面我们以例子来解说proftp的配置,这样大家可能更加容易理解。

1ftp服务器支持断点续传,且最大支持同时10人在线,每个ip只允许一个连接;

2。允许ftpusers用户组只能访问自己的目录,而不能访问上级或者其他目录;

3。用户登陆服务器时不显示ftp服务器版本信息,以增加安全性;

4。建立一个kaoyanftp帐户,属于ftpusers组,kaoyan用户只允许下载,没有可写的权限。下载速率限制在50Kbytes/s

5。建立一个upload用户,也属于ftpusers组,同kaoyan用户的宿主目录一样,允许upload用户上传文件和创建目录的权限,但不允许下载,并且不允许删除目录和文件的权限,上传的速率控制在100Kbytes/s

先是前期的用户和组添加以及目录的权限设置

group add ftpusers

useradd -d /home/kaoyan -g ftpusers -s /bin/fales kaoyan

useradd -d /home/kaoyan -g ftpusers -s /bin/fales upload

chown -R kaoyan:upload /home/kaoyan

chmod -R 775 /home/kaoyan

如果你只想ftpusers组的用户访问,可以设置成770都行。

设置/usr/local/proftpd/etc/proftpd.conf

注意#表示注释,对设置没影响,可以不写

ServerName "Frank's FTP Server"

ServerType standalone

DefaultServer on

Port 21

Umask 022

MaxInstances 30 #最多有30proftpdPID

User nobody

Group nobody

TimeoutStalled 10

MaxClients 10 #最多允许10个用户在线

MaxClientsPerHost 1 "对不起,一个IP只允许一个连接"

AllowStoreRestart on

#允许断点续传(上传),断点续续(下载)是默认支持的,不用设置

DisplayLogin welcome.msg #欢迎词文件

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

DefaultRoot ~ ftpusers #设置ftpusers组只能访问自己的目录

<Directory />

AllowOverwrite on

</Directory>

<Directory /home/kaoyan>

<Limit WRITE> #不允许写

DenyUser kaoyan

</Limit>

<Limit RMD RNFR DELE RETR> #不允许删除,改名,下载

DenyUser upload

</Limit>

TransferRate RETR 50 user kaoyan

TransferRate STOR 100 user upload

</Directory>

我这里实现的方式还可以通过

 

<Anonymous ~kaoyan>

...

...

</Anonymous>

<><Anonymous ~upload>

...

...

</Anonymous>

而且更加灵活,具体用那种方式,看大家了

转载于:https://my.oschina.net/wenic705/blog/15681

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值