利用ProFTPD Linux下简单架设FTP服务器

间隙填充
正睿科技  发布时间:2007-09-17 09:19:27  浏览数:2548

【编者按】

  ProFTPD是一个Unix平台或类Unix平台(如Linux、FreeBSD等)的FTP服务器程序,它是在自由软件基金会的版权声明(GPL)下开发、发布的免费软件,任何人只要遵守GPL版权声明,都可以随意修改源始码。ProFTPD是使用最广泛的wu-ftpd的改进版,它修正了wu-ftpd的许多缺陷,在许多方面进行了重大的改进,其中一个重要变化就是它学习了Apache的配置方式,使proftpd的配置和管理更加简单易懂。下面,小编就带领大家一起在Linux系统下利用ProFTPD架设一台FTP服务器。 

【正文】
 
  ProFTPD是一个Unix平台或类Unix平台(如Linux、FreeBSD等)的FTP服务器程序,它是在自由软件基金会的版权声明(GPL)下开发、发布的免费软件,任何人只要遵守GPL版权声明,都可以随意修改源始码。ProFTPD是使用最广泛的wu-ftpd的改进版,它修正了wu-ftpd的许多缺陷,在许多方面进行了重大的改进,其中一个重要变化就是它学习了Apache的配置方式,使proftpd的配置和管理更加简单易懂。下面,小编就带领大家一起在Linux系统下利用ProFTPD架设一台FTP服务器。

  一、软件相关资源

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

  源码软件包:proftpd是开源的软件,可以去其官方网站下载。

  帮助文档: 软件包中包含。

  FAQ:软件包中包含。

  配置文件样例:软件包中包含。

  二、软件的安装

  1、安装

  在官方网站中下载源码软件包proftpd-1.2.10. tar.gz,接下来将对安装过程的一些重要步骤给出解释:

  [root@localhost root]

  #tar xzvf proftpd-1.2.10. tar.gz

  [root@localhost root]

  #cd bind-9.3.1

  [root@localhost bind-9.3.1]

  #./configure

  [root@localhost bind-9.3.1]

【正文】
 
  #make

  [root@localhost bind-9.3.1]

  #make install

  tar xzvf bind-9.3.1.tar.gz 解压缩软件包

  ./configure 针对机器作安装的检查和设置,大部分的工作是由机器自动完成的,但是用户可以通过一些参数来完成一定的设置,其常用选项有:

  ./configure --help 察看参数设置帮助

  --enable-ipv6 支持ipv6

  可以设置的参数很多,可以通过 -help察看需要的,一般情况下,默认设置就可以了。

  默认情况下,安装过程应该建立:

  proftpd的deamon为/usr/local/sbin/proftpd

  proftpd的配置文件,/usr/local/etc/proftpd.conf

  2、启动

  [root@localhost root]

  # /usr/local/sbin/proftpd -c

  /usr/local/etc/proftpd.conf

  -c选项用来指定配置文件的位置,不指定的话默认位置是/usr/local/etc/proftpd.conf。

  正常情况下proftpd应该启动了,ps aux 应该可以查到proftpd的进程,或netstat -an 也可以看到21端口的服务已经起来了。

  如果要设置开机自启动ftp server,只需在/etc/rc.d/rc.local中加入一行

  /usr/local/sbin/proftpd

  #!/bin/sh

  # This script will be executed

  *after* all the other init scripts.

  # You can put your own

  initialization stuff in here if you don’t

  # want to do the full Sys V style init stuff.

  touch /var/lock/subsys/local

  /usr/local/sbin/proftpd

  三、软件的配置

  1、初始配置文件

  默认配置文件的位置为:/usr/local/etc/proftpd.conf,如果文件不存在可以从压缩包中把配置文件样例拷贝过来即可。下面逐项分析其中一些常选项:(#后面的部分是注释)

  # This is a basic ProFTPD

  configuration file

  # ’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 

  ServerType

  standalone

  DefaultServer

  on

  # Port 21 is the standard FTP port.

  Port 21

  ServerType指定FTP Server的启动类型,一般使用standalone方式比较简单,如果访问量不大,为节省资源考虑用xinetd侦听启动,必须在这里指定。Port指定FTP的侦听端口,一般使用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

  Umask指定FTP server进程的Umask值,022与Linux系统得默认值一致。

  MaxInstances指定FTP server的最大连接数。

  # 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

  User和Group指定proftpd进程启动时的有效用户ID,处于安全考虑默认的身份是nobody,有一点要指出的是,一般Red Linux 9.0中默认是没有nogroup这个组的,把Group指定为nobody即可。

  DefaultRoot选项限制Linux系统用户通过FTP方式登录时将被限制在其home目录下。

  # Set the maximum number of seconds

  a data connection is allowed

  # to "stall" before being aborted.

  #TimeoutStalled   300

  AllowRetrieveRestart   on

  AllowStoreRestart    on

  # Normally, we want files to be overwriteable.

  AllowOverwrite      on

  TimeoutStalled 指定一个连接的超时时间。

  AllowRetriveRestart 和AllowStroeRestart 指定允许断点续传。

  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

  DenyAll

  2、配置文件结构分析

  #全局设置

  设置项目1 参数1

  设置项目2 参数2

  #某个目录的设置
  ...

  #关于匿名登陆的设置
  ...

  常用全局设置:

  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用户登录,默认是不允许的,安全起见不推荐此选项。