ProFTPD 服务器

本科毕业设计所设计的系统需要用到一个ftp服务器。我选择的是ProFTPD服务器。

一.ProFTPD 服务器介绍

ProFTPD is a highly configurable FTP daemon for Unix and Unix-like
operating systems.  


二.官方地址

http://www.proftpd.org/

三.安装步骤

  1. 解压下载的文件

  2. 命令终端进入到解压后的文件目录(该目录一般和解压之前的文件名同名)

  3. 输入    ./configure

  4. 输入   make

  5. 输入   sudo make install

    注:更详细的说明,请参考解压后的文件中的INSTALL文件


四.创建 ftp组以及ftp用户

  为了使匿名用户登录进系统之后具有访问目录的权限,需要创建一个锁定的用户“ftp”,并把该“ftp”用户归到"ftp"group中。

   使用的命令有:

   1.sudo groupadd ftp

   2.sudo useradd ftp -g ftp -d /host/LIVES


五.配置文件 proftpd.conf

proftpd.conf 一般位于  /usr/local/etc 目录,下面给出一种配置文件,它是我毕业设计所需的。

 
 
  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. ServerName          "ProFTPD Default Installation"

  6. ServerType          standalone

  7. DefaultServer           on

  8. # Port 21 is the standard FTP port.

  9. Port                21

  10. # Don't use IPv6 support by default.

  11. UseIPv6             off

  12. # Umask 022 is a good standard umask to prevent new dirs and files

  13. # from being group and world writable.

  14. Umask               022

  15. # To prevent DoS attacks, set the maximum number of child processes

  16. # to 30.  If you need to allow more than 30 concurrent connections

  17. # at once, simply increase this value.  Note that this ONLY works

  18. # in standalone mode, in inetd mode you should use an inetd server

  19. # that allows you to limit maximum number of processes per service

  20. # (such as xinetd).

  21. MaxInstances            30

  22. # Set the user and group under which the server will run.

  23. User                nobody

  24. Group               nogroup

  25. # To cause every FTP user to be "jailed" (chrooted) into their home

  26. # directory, uncomment this line.

  27. DefaultRoot /host/LIVES

  28. # Normally, we want files to be overwriteable.

  29. AllowOverwrite      on

  30. # Bar use of SITE CHMOD by default

  31. <Limit SITE_CHMOD>

  32.  DenyAll

  33. </Limit>

  34. # A basic anonymous configuration, no upload directories.  If you do not

  35. # want anonymous users, simply delete this entire <Anonymous> section.

  36. <Anonymous /host/LIVES/users>

  37. <Limit LOGIN>

  38. AllowAll

  39. </Limit>

  40.  RequireValidShell off

  41.  User              ftp

  42.  Group             ftp

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

  44.  UserAlias         anonymous ftp

  45.  # Limit the maximum number of anonymous logins

  46.  MaxClients            10000

  47.  # We want 'welcome.msg' displayed at login, and '.message' displayed

  48.  # in each newly chdired directory.

  49.  DisplayLogin          welcome.msg

  50.  DisplayChdir          .message

  51.  # Limit WRITE everywhere in the anonymous chroot

  52. <Limit WRITE>

  53.    AllowAll

  54. </Limit>

  55. <Limit READ>

  56.  AllowAll

  57. </Limit>

  58. <Limit STOR>

  59.  AllowAll

  60. </Limit>

  61. </Anonymous>

上面配置的效果是: 将所有匿名用户的操作目录限制在 “/host/LIVES/users",匿名用户可以读写修改目录和文件。当然还有其他的功能,在此不一一细说1.gif

六.方便操作的shell脚本

脚本名称:proftpd.sh

 
 
  1. #!/bin/sh

  2. # ProFTPD files

  3. FTPD_BIN=/usr/local/sbin/proftpd

  4. FTPD_CONF=/usr/local/etc/proftpd.conf

  5. PIDFILE=/usr/local/var/proftpd.pid

  6. # If PIDFILE exists, does it point to a proftpd process?

  7. if [ -f $PIDFILE ]; then

  8.  pid=`cat $PIDFILE`

  9. fi

  10. if [ ! -x $FTPD_BIN ]; then

  11.   echo "$0: $FTPD_BIN: cannot execute"

  12.   exit 1

  13. fi

  14. case $1 in

  15.   start)

  16.     if [ -n "$pid" ]; then

  17.       echo "$0: proftpd [PID $pid] already running"

  18.       exit

  19.     fi

  20.     if [ -r $FTPD_CONF ]; then

  21.       echo "Starting proftpd..."

  22.       $FTPD_BIN -c $FTPD_CONF

  23. else

  24.       echo "$0: cannot start proftpd -- $FTPD_CONF missing"

  25.     fi

  26.     ;;

  27.   stop)

  28.     if [ -n "$pid" ]; then

  29.       echo "Stopping proftpd..."

  30.       kill -TERM $pid

  31. else

  32.       echo "$0: proftpd not running"

  33.       exit 1

  34.     fi

  35.     ;;

  36.   restart)

  37.     if [ -n "$pid" ]; then

  38.       echo "Rehashing proftpd configuration"

  39.       kill -HUP $pid

  40. else

  41.       echo "$0: proftpd not running"

  42.       exit 1

  43.     fi

  44.     ;;

  45.   *)

  46.     echo "usage: $0 {start|stop|restart}"

  47.     exit 1

  48.     ;;

  49. esac

  50. exit 0

该脚本的使用方法:

  1. sudo      ./proftpd.sh start  

  2. sudo     ./proftpd.sh restart

  3. sudo      ./proftpd.sh stop

它们的含义是显而易见的,值得注意的是"./proftpd restart"并不会关闭已经开启的进程,而是重新读取配置文件,这样后来开启的进程使用的都是刚读入的配置文件。


你可能感兴趣的:(服务器,ftp,proFTPD)