⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftp服务器配置!.htm

📁 台大计中UNIX讲义
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0048)http://www.linuxforum.net/books/jy/G.928504748.A -->
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY><PRE>发信人: albin (阿乐斌), 信区: LINUX
标  题: LINUX选修课讲义:FTP服务器配置!
发信站: 碧海青天 (Fri Jun  4 23:01:56 1999), 转信

版权声明:
    本文内容为大连理工大学LINUX选修课讲义,欢迎大家转载,但禁止使用本材料进行
    任何商业性或赢利性活动。转载时请保留本版权声明。

    作者:何斌武,hbwork@dlut.edu.cn,大连理工大学网络中心,April 1999.

    URL: ftp://ftp.dlut.edu.cn/pub/PEOPLE/albin/
------------------------------------------------------------------------------
FTP服务器的安装及管理

说明:
    因时间关系,没有对具体细节作详细说明,请参考wu-ftp FAQ以及ftpd,ftpaccess
    的在线文档(man ftpd).
    
一. ftp服务器
1. inetd配置文件或xinetd.conf配置文件
   /etc/inetd.conf文件内容如下:
   ftp     stream  tcp     nowait  root    /usr/sbin/tcpd  in.ftpd -l -a 

   /etc/xinetd.conf文件内容如下:
   service ftp
   {
           socket_type     = stream
           protocol        = tcp
           wait            = no
           user            = root
           #only_from       = 202.118.66.0
           #only_from       += 192.168.1.2
           #only_from       += localhost   
           server          = /usr/sbin/in.ftpd
           server_args     = -l -a
   }                                


   相关文件:/etc/services
   ftp-data        20/tcp
   ftp             21/tcp 

2. ftp用户(Anonymous FTP服务器需要用到)
   文件:/etc/passwd和/etc/shadow
   
   /etc/passwd:
   ftp:x:500:50:Anonymous FTP User:/home/ftp:/bin/false 

   /etc/shadow:
   ftp:*:10689:0:99999:7::: 

   $finger ftp
   Login: ftp                              Name: FTP User
   Directory: /home/ftp                    Shell: /bin/false
   Never logged in.
   No mail.
   No Plan.              
   
3. DNS配置
   ftp  IN      CNAME   officail.domain.name.

4. 管理员邮件别名
   文件: /etc/mail/aliases (Solairs)
         /etc/aliases      (Linux)
         (egrep aliases /etc/mail/sendmail.cf )
 
    ftp-admin:  real-user-name@domain.name

    相关命令: newaliases, 建立邮件别名


二. 文件系统结构
 1. Anonymous FTP 目录结构
    如下子目录:
    bin(ls,gzip,tar等anonymous ftp用户所要使用的二进制可执行文件)
    etc(passwd,group)
    lib(动态连接库,ld-2.0.7.so, ld-linux.so.2, ldd ../bin/ls 等)
    pub(可下载文件)

 2. passwd及group文件
    不要使用系统的passwd及group文件,最好只放所需的用户及组信息
 passwd文件:
    ftpadm:x:0:0:Anonymous FTP:/home/ftp:/bin/false
    ftp:x:60000:60000:Anonymous FTP:/home/ftp:/bin/false 
 group文件:
    ftpadmin:x:0:
    ftp:x:60000:

 3. 文件及目录属性
 主目录/home/ftp   属主root, 属性555
 bin    属主root 组wheel或other, 属性111
 etc    同上
 lib    属主root, 属性555
 pub    属主为root或ftp管理员,属性555
 
 确认不要用ftp作任何文件或目录的属主!

 [hbwork@helius /etc]$ cd /home/ftp/
 [hbwork@helius ftp]$ ls -l
 total 4
 d--x--x--x   2 root     root         1024 Apr  8 17:57 bin
 d--x--x--x   2 root     root         1024 Jun  4 15:12 etc
 drwxr-xr-x   2 root     root         1024 Apr  8 17:57 lib
 dr-xr-sr-x   2 root     ftp          1024 Apr  8 11:18 pub 
 
 $ls -l bin
 [root@helius ftp]# ls -l bin/
 total 250
 ---x--x--x   1 root     root        15236 Apr 28  1998 compress
 ---x--x--x   1 root     root        46356 Sep 11  1998 cpio
 ---x--x--x   1 root     root        45436 Sep 11  1998 gzip
 ---x--x--x   1 root     root        29980 Sep 11  1998 ls
 ---x--x--x   1 root     root       110668 Sep 11  1998 tar
 lrwxrwxrwx   1 root     root            4 May 19 16:48 zcat -&gt; gzip  

 $ls -l etc
 total 19
 -r--r--r--   1 root     root           57 Jun  4 15:12 group
 -r--r--r--   1 root     root        16372 Sep 11  1998 ld.so.cache
 -r--r--r--   1 root     root           83 Jun  4 15:12 passwd 

(在Solaris上建立anonymouse FTP特殊一些,请参考Wu-ftpd-faq)


 4. 可选目录
    incoming    Owner: root   Mode:1733 (chmod 1733 incoming)

三. 测试及调试
   egrep ftp /etc/inetd.conf
   ps ax |egrep inetd
   kill -HUP $PID

   $ftp localhost (or ftp 0)
   执行ls cd get 等指令看一下结果如何


四. wu-ftpd FTP服务器进程

   增强功能:
     . 允许根据用户的ip地址或主机,用户名设置不同的类
     . 根据设置的类,管理员可以控制其访问权限,如防止anonymous用户
       删除文件或覆盖已有的文件
     . 可以实现自动执行uncompress,compress,tar,gzip等功能
     . 可以记载所有的upload/download,及ftp client所发送的每个命令.
     . 允许平滑关掉ftp服务器

   相关配置文件:
       ftpaccess
       ftpconversions
       ftphosts
       ftpuser
       
       相关命令:
           strings /usr/sbin/in.ftpd |egrep ftpaccess

1. 编译 wu-ftpd

   最新版本: wu-ftpd-2.5.0
     ftp://ftp.dlut.edu.cn/pub/unix/ftp/servers/

   $tar -zxvf wu-ftpd-2.5.0.tar.gz
   $cd wu-ftpd-2.5.0
     建议在编译安装之前参考文件INSTALL,README,upload.configuration.HOWTO 
     如想定制自己的wu-ftpd,可编辑文件src/pathnames.h
   $build help
      查看编译帮助
      
   $./build lnx
   $su
   #./build install

2. 命令行选项
   -d   Sends debugging information to syslog
   -a   Enable the use of the ftpaccess file(This is the default)
   -A   Disable the use of the ftpaccess file
   -L   Cause ftpd to log all USER commands.
   -i   Causes ftpd to log all incoming(upload) file in the xferlog 
        file( See pathnames.h )
   -o   Causes ftpd to log all outgoing(download) files in the xferlog file

3. 文件ftpconversions
   doc/examples/, 用于指定get时的实时压缩或展开(on-the-fly).

   此文件不般情况下不用作修改

4. ftpaccess
  (1)定义类
      三种用户类型: real anonymous 
                    guest(需要提供相应的口令)
      格式:
        class classname type[,type,...] address [ address ...]
  
      示例:
        class local real *.dlut.edu.cn 202.118.66 localhost
        class anonymous anonymous *


  (2)拒绝访问
     deny *.net.cn      /etc/ftpmsgs/msg.denied

  (3)限制访问
     limit class number times messages

     limit anonymous 200 SaSu
     limit anonymous 100 Any    /etc/ftpmsgs/msg.toomany

     
     loginfails 2 
     tar no anonymous
     compress no anonymous

     chmod      yes|no type [type ...]
     delete     yes|no type [type ...]
     overwrite  yes|no type [type ...]
     rename     yes|no type [type ...]
     umask      yes|no type [type ...]
     
     passwd-check       none|trivial|rfc822     enforce|warn

   (5)banner
      显示在用户login之前的信息
      banner    /etc/ftpmsg/banner.msg

      其中banner.msg文件中可以引用如下变量:
      %C        Current working directory
      %E        Email address of the administrator( email ftpadm@dlut.edu.cn)
      %F        可当目录下可用空间
      %L        hostname 
      %M        最大允许连接数
      %N        同一类中当前连接数
      %R        The client host'name or ip address
      %T        Current local time
      %U        The name the user specified at login

      示例文件:
      Welcome to this test FTP Archive, running on %L.

      Please contact %E with any technical problems you may have
      accessing this archive.

      You are currently user %N out of a maximum %M users. It's
      %T in PRC.    

   (6)message命令
     message pathname login
     message pathname cwd=dir
     message .conents cwd=* 
             每改变目录均显示,cwd=dir只在第一次更改时显示

   (7)readme命令
      readme pathname [login|cwd=dir] [class] [class]

      readme README* cwd=*

   (8)shutdown命令 (2.5.0上不正常)
      shutdown pathname

   (9)log命令

      log commands type [ type ...]

      log transfer type [type ...] direction[,direction]

   (10)alias 
       alias source: /pub/local/sw/source

   (11)cdpath
       cdpath /pub /pub1

上载控制
   upload hierarchy directory yes|no owner group mode [dirs|nodirs]

下面的wu-ftpd-2.5.0 /etc/ftpaccess文件中的upload配置(大家可以试一下大工FTP
服务器的upload,但别传没用的过大的文件)

# FTP-home-dir          archiv-dir      allow?  owner   group   mode    dirs?
# (as in /etc/passwd)

upload  /home/ftp       *               no
upload  /home/ftp       /pub3/incoming/windows yes ftpadmin ftp  0664  dirs
upload  /home/ftp       /pub3/incoming/windows/* yes ftpadmin ftp 0664 dirs
upload  /home/ftp       /pub3/incoming/unix     yes     ftpadmin ftp   0666 dirs
upload  /home/ftp       /pub3/incoming/unix/*   yes     ftpadmin ftp   0666 dirs
upload  /home/ftp       /pub3/incoming/other    yes     ftpadmin ftp   0666 dirs
upload  /home/ftp       /pub3/incoming/other/*  yes     ftpadmin ftp   0666 dirs
upload  /home/ftp       /pub3/incoming/WDI      yes     ftpadmin ftp   0666 dirs
upload  /home/ftp       /pub3/incoming/WDI/*    yes     ftpadmin ftp   0666 dirs


5. ftphosts文件
   allow ftp    *.dlut.edu.cn
   allow anonymous *.dlut.edu.cn
   deny ftp *.dlmu.edu.cn
   deny ftp *.dlmu.edu.cn 202.118.80.*


6.实用程序

  ftpcount
  ftpwho
  ftushut

维护:
    建立连接时最好使用相对路径。
    根据软件类别建立不同的子目录。
    最好在每个目录中建立相应的说明文件或index文件,方便用户查找。

参考资料: wu-ftp FAQ
  

     


--
※ 来源:.碧海青天 bbs.dlut.edu.cn.[FROM: helius.dlut.edu.]
</PRE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -