• 网络学院
  • IT资讯
  • 操作系统
  • 网络技术
  • 软件应用
  • 办公软件
  • 编程技术
  • 网站架设
  • 数据库类
  • 平面设计
  • 多媒体类
  • 游戏资讯
  • 教学论文
  • 认证考试
用Linux架设FTP服务器(下)
  站点:
  • 首 页
  • 最新软件
  • 文章教程
  • 国内软件
  • 国外软件
  • 绿色软件
  • 源码下载
  • 字体下载
用Linux架设FTP服务器(下)
软件发布 用Linux架设FTP服务器(下)
网络软件 系统工具 应用软件 联络聊天 图形图像 多媒体类 行业软件 游戏娱乐 编程开发 安全相关 教育教学 数码软件 绿软下载
热门软件: QQ 瑞星 pplive e话通 木马克星 千千静听 office2000 五笔字根 Photoshop 视频分割
返回文章教程首页 >> 文章首页 >> 网络技术 >> FTP服务器架设与维护 >> 用Linux架设FTP服务器(下)

用Linux架设FTP服务器(下)

添加时间: 2007-8-31 21:07:47  作者: FTP服务器教程  阅读次数:25   来源: http://www.d9soft.com

       

message
  “message”设置当用户登录或转到一个目录的时候会收到什么消息。可以设定多个消息。命令的格式为:

  message <path> <when>

  <path>表示需要显示的文件的完整路径名,<when>和“readme”中的<when>意思一样。

  还需要注意的是消息文件的路径名也是相对于匿名ftp目录的。

  例如:

  message /home/ftp/.welcome.msg LOGIN

  compress、tar、chmod、delete、overwrite、rename

  如果这些都不设置,那么就使用默认值,也就是对所有人都是“yes”。下面例子中的设置的意思是给guest组chmod、delete、overwrite和rename文件的权力,所有人都可以使用compress和tar。

  例如:

  compress yes all
  tar yes all
  chmod yes guest
  delete yes guest
  overwrite yes guest
  rename yes guest

  log commands

  因为安全上的原因需要记录用户使用的每一个命令。“log commands”的格式是:

  log commands <typelist>

  <typelist>是用逗号隔开的字串,表示哪些用户的命令需要记录下来,字串的取值可以是:anonymous、guest或real。

  例如:要记录real和guest用户的每一个命令,可以这么表示:

  log commands real,guest

  这些记录都保存在“/var/log/message”文件中。

  log transfers

  因为安全文件需要把文件的传输都记录下来。“log transfers”的格式是:

  log transfers <typelist> <directions>

  <typelist>是用逗号隔开的字串,表示哪些用户的命令需要记录下来,字串的取值可以是:anonymous、guest或real。<direction>也是用逗号隔开的字串,设置需要记录的文件传输的方向,可以选择的两个传输方向是“inbound”(向内)和“outbound”(向外)。

[page]

例如,用下面表示记录所有real和guest用户的“inbound”和“outbound”方向的文件传输:


  log transfers real,guest inbound,outbound

  这些记录保存在“/var/log/xferlog”文件中。


  guestgroup

  这个命令用来设置guest组,每一行只能有一个成员。

  例如:

  guestgroup ftpadmin
  guestgroup webmaster


  log security

  用来设置记录real、guest或anonymous用户违反安全规则的行为。

  log security <typelist>

  <typelist>是用逗号隔开的字串,字串的取值可以是:anonymous、guest或real。“real”表示真正在FTP服务器上有帐号的用户,“anonymous”表示匿名用户,“guest”表示guest用户。

  例如:

  log security real,guest

  restricted-uid、restricted-gid、guest-root

  这些用来设置是否允许real和guest用户访问家目录之外的目录。格式为:

  guest-root <root-dir>
  restricted-uid <uid-range>
  restricted-gid <gid-range>

  例如:

  guest-root /home/ftp ftpadmin webmaster
  restricted-uid ftpadmin webmaster
  restricted-gid adminftp webmaster

  <root-dir>设置chroot环境的用户路径。在一行里可以有多个uid地范围。如果为用户设置了guest-root,那么该用户的家目录就在“<root-dir>/etc/passwd”文件中设定,而“/etc/passwd”文件中的设定是无效的。当“ftpadmin”和“webmaster”被改变了根目录(chrooted)到“/home/ftp”目录下,他们就被限制在各自的家目录下而不能访问别人的文件。

  greeting

  设置用户登录时候的欢迎信息。格式为:

  greeting fullbriefterse

  “greeting full”是默认的设置显示主机名和ftp daemon地版本,“greeting brief”显示主机名,“greeting terse”简单地显示“FTP server ready”。

  例如:

  greeting terse


  keepalive <yesno>

  设置socket的TCP SO_KEEPALIVE参数。这样在必要的时候可以断开网络连接。“yes”有效,“no”无效。最好设成“yes”:

  Keepalive yes

[page]

配置“/etc/ftphosts”文件
  “/etc/ftphosts”文件为每一个用户建立规则,指定允许用户从某个主机登录ftp服务器,或者不允许用户从某个主机登录ftp服务器。


  创建“ftphosts”文件(touch /etc/ftphosts),加入下面这几行:

  # Example host access file
  #
  # Everything after a ‘#‘ is treated as comment,
  # empty lines are ignored
  allow ftpadmin 208.164.186.1 208.164.186.2 208.164.186.4

  把文件的权限改为600:

  [root@deep]# chmod 600 /etc/ftphosts

  每一行可能是:

  allow <username> <addrglob>

  或

  deny <username> <addrglob>

  “allow”允许用户用<username>用户名,从<addrglob>地址访问ftp服务器。<addrglob>可以包含多个地址。

  “deny”禁止用户名为<username>的用户,从<addrglob>地址访问ftp服务器。<addrglob>可以包含多个地址。

  配置“/etc/ftpusers”文件
  “/etc/ftpusers”文件设置哪些用户不允许连接到ftp服务器。

  创建“ftpusers”文件(touch /etc/ftpusers),加入下面这几行:

  root
  bin
  daemon
  adm
  lp
  sync
  shutdown
  halt
  mail
  news
  uucp
  operator
  games
  nobody

  把文件的权限设成600:

  [root@deep]# chmod 600 /etc/ftpusers

  配置“/etc/ftpconversions”文件
  “/etc/ftpconversions”是用来控制当传输文件的时候是否进行压缩。

  创建“ftpconversions”文件(touch /etc/ftpconversions),在文件中加入:

  :.Z: : :/bin/compress -d -c %s:T_REGT_ASCII:O_UNCOMPRESS:UNCOMPRESS
  : : :.Z:/bin/compress -c %s:T_REG:O_COMPRESS:COMPRESS
  :.gz: : :/bin/gzip -cd %s:T_REGT_ASCII:O_UNCOMPRESS:GUNZIP
  : : :.gz:/bin/gzip -9 -c %s:T_REG:O_COMPRESS:GZIP
  : : :.tar:/bin/tar -c -f - %s:T_REGT_DIR:O_TAR:TAR
  : : :.tar.Z:/bin/tar -c -Z -f - %s:T_REGT_DIR:O_COMPRESSO_TAR:TAR+COMPRESS
  : : :.tar.gz:/bin/tar -c -z -f - %s:T_REGT_DIR:O_COMPRESSO_TAR:TAR+GZIP
  : : :.crc:/bin/cksum %s:T_REG::CKSUM
  : : :.md5:/bin/md5sum %s:T_REG::MD5SUM

  把文件的属性改为600:

  [root@deep]# chmod 600 /etc/ftpconversions

  配置“/etc/pam.d/ftp”文件
  配置“/etc/pam.d/ftp”文件使其支持PAM安全验证。

[page]

创建“ftp”文件(touch /etc/pam.d/ftp)并加入:


  #%PAM-1.0
  auth required /lib/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
  auth required /lib/security/pam_pwdb.so shadow nullok
  auth required /lib/security/pam_shells.so
  account required /lib/security/pam_pwdb.so
  session required /lib/security/pam_pwdb.so

  配置“/etc/logrotate.d/ftpd”文件
  配置“/etc/logrotate.d/ftpd”文件使得日志文件每周自动循环更新。

  创建“ftpd”文件(touch /etc/logrorate.d/ftpd)并加入:

  /var/log/xferlog {
  # ftpd doesn‘t handle SIGHUP properly
  nocompress
  }

  配置ftp使其使用inetd超级服务器(用于实现tcp-wrappers)
  tcp-wrappers用来启动和中止ftpd服务。当inetd执行的时候,它会从默认为“/etc/inetd.conf”的配置文件读入配置信息。配置文件中每一行中的项用TAB或空格隔开。

  编辑inetd.conf文件(vi /etc/inetd.conf),加入并验证是否存在下面这一行: ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a

  注意:更新完“inetd.conf”文件之后要发给inetd一个SIGNUP信号,运行下面的命令:

  [root@deep /root]# killall -HUP inetd

  编辑“hosts.allow”文件(vi /etc/hosts.allow)加入这一行:

  in.ftpd: 192.168.1.4 win.openarch.com

  这表示IP地址为“192.168.1.4”并且主机名为“win.openarch.com”的计算机允许访问ftp服务器。

  FTP管理工具
  ftpwho
  ftpwho显示当前连接到ftp服务器上的所有用户。这个命令菜单输出类似“/bin/ps”的输出,其格式为:

  <pid> <time> <tty> <connection details>

  其中<pid>表示ftp daemon用来处理这次文件传输的进程号,<time>表示用户什么时候连接到ftp服务器上,<tty>总是用问号(?)表示因为是通过ftp而不是telnet连接,<connection details>告诉连接是来自哪里、用户是谁以及用户现在在干什么。

  下面是ftpwho输出的一个例子:

  [root@deep]# ftpwho

  Service class openarch:
  5443 ? S 0:00 ftpd: win.openarch.com: admin: IDLE
  - 1 users ( 20 maximum)

[page]

可以看到现在有一个用户登录(最多可以有20个用户同时登录),这个用户的用户名是admin来自win.openarch.com。


  ftpcount
  ftpcount是ftpwho的简化版,只显示登录到ftp服务器的用户数以及最多允许多少个用户登录。下面是一个例子:

  [root@deep]# ftpcount

  Service class openarch - 1 users ( 20 maximum)

  保证ftp服务器的安全

  首先确保已经创建了“/etc/ftpusers”文件,这个文件用来设置不允许哪些用户登录ftp服务器,其中至少要包括:root、bin、daemon、adm、lp、sync、shutdown、halt、mail、news、uucp、operator、games、nobody以及所有Linux发行商在系统中提供的默认帐号。

  如果想禁止匿名ftp服务,把ftp用户从password文件中移去,再用下面的命令确定在系统中没有安装anonftp-version.i386.rpm软件包:

  [root@deep]# rpm -q anonftp.

  upload命令

  在默认情况下,WU-FTPD服务器给所有的guest用户上载的权限。当用户登录的时候,被改变根目录(chroot)到“/home/ftp”就不能访问这个目录之外的地方。但是“/home/ftp”目录中的一些地方还是需要保护,不能让用户随便访问。在我们配置的ftp服务器中为“/home/ftp”目录下的“bin”、“etc”、“dev”和“lib”目录。我们不允许用户上载文件到这些目录。所以我们要为这些目录设置访问权限,可以在“/etc/ftpaccess”文件中设置上载权限。在我们的例子中是这样设置的:

  upload /home/ftp/* / no
  upload /home/ftp/* /etc no
  upload /home/ftp/* /dev no
  upload /home/ftp/* /bin no (require only if you are not using the “--enable-ls” option)
  upload /home/ftp/* /lib no (require only if you are not using the “--enable-ls” option)

  noretrieve命令

  最好禁止某些用户从“/home/ftp”目录下的某些子目录中下载文件,可以用“noretrieve”命令在“/etc/ftpaccess”文件中设置。

  noretrieve /home/ftp/etc
  noretrieve /home/ftp/dev
  noretrieve /home/ftp/bin (require only if you are not using the “--enable-ls” option)
  noretrieve /home/ftp/lib (require only if you are not using the “--enable-ls” option)

  “.notar”文件
  无论是否允许即时的目录打包(on-the-fly tar),都必须保证用户不能打包(tar)禁止上载的目录。在“/home/ftp”目录的每个子目录中都创建“.notar”文件。

  [root@deep]# touch /home/ftp/.notar
  [root@deep]# chmod 0 /home/ftp/.notar
  [root@deep]# touch /home/ftp/etc/.notar
  [root@deep]# chmod 0 /home/ftp/etc/.notar
  [root@deep]# touch /home/ftp/dev/.notar
  [root@deep]# chmod 0 /home/ftp/dev/.notar
  [root@deep]# touch /home/ftp/bin/.notar (require only if you are not using the “--enable-ls” option)
  [root@deep]# chmod 0 /home/ftp/bin/.notar (require only if you are not using the “--enable-ls” option)
  [root@deep]# touch /home/ftp/lib/.notar (require only if you are not using the “--enable-ls” option)
  [root@deep]# chmod 0 /home/ftp/lib/.notar (require only if you are not using the “--enable-ls” option)

[page]

这些长度为0的“.notar”文件会使一些浏览器和ftp代理(proxy)出现混乱,要解决这个问题必须把它们标识为禁止下载。在“/etc/ftpaccess”文件中加入这一行:


  noretrieve .notar

  安装到系统中的文件

  > /etc/ftphosts
  > /etc/ftpusers
  > /etc/ftpaccess
  > /etc/pam.d/ftp
  > /etc/ftpconversions
  > /etc/ftpgroups
  > /etc/logrotate.d/ftpd
  > /usr/bin/ftpcount
  > /usr/bin/ftpwho
  > /usr/man/man1/ftpcount.1
  > /usr/man/man1/ftpwho.1
  > /usr/man/man5/ftpaccess.5
  > /usr/man/man5/ftphosts.5
  > /usr/man/man5/ftpconversions.5
  > /usr/man/man5/xferlog.5
  > /usr/man/man8/ftpd.8
  > /usr/man/man8/ftpshut.8
  > /usr/man/man8/ftprestart.8
  > /usr/sbin/in.ftpd
  > /usr/sbin/ftpshut
  > /usr/sbin/ckconfig
  > /usr/sbin/ftprestart
  > /usr/sbin/xferstats
  > /usr/sbin/wu.ftpd
  > /usr/sbin/in.wuftpd
  > /var/log/xferlog

 

上下文章:

 

上一篇文章: FTP服务器如何实现安全性 上 下一篇文章: 小组开发环境搭建(五)

相关文章:

  • Linux之父:最烦安全人士大肆宣扬软件漏洞
  • 腾讯QQ for Linux的后续改进计划
  • 用端口碰撞技术实现服务器远程管理
  • 以MDaemon为例解释邮件服务器的安全设置
  • 用Windows Server 2003架设小型邮件服务器

相关软件:

  • 北信源VRV 网络服务器端病毒库 90e
  • Sawmill for Linux V7.2.1
  • 勤哲Excel服务器 2005 V6.0 企业版客户端
  • 勤哲Excel服务器 2005 V6.0 企业版服务器端
  • 勤哲Excel服务器 2005 V5.8.3 完整标准版
  • 勤哲Excel服务器 2005 V6.0 标准版

 

快速导航

  • 网络学院
  • 精品汇聚
  • 字体下载
  • 教程下载
  • ASP源码
  • PHP源码
  • Net源码
  • JSP 源码

网络技术分类导航

  • 局域网专栏
  • 病毒快报
  • 网络安全
  • 组网教程
  • WEB服务器架设与维护
  • FTP服务器架设与维护
  • DNS服务器架设与维护
  • 邮件服务器架设与维护

本类经典文章推荐

  • FlashFTP教程
  • FTP服务器端软件Serv-U教程(1)
  • FTP服务器端软件Serv-U教程(2)
  • FTP服务器端软件Serv-U教程(3)
  • FTP服务器端软件Serv-U教程(4)
  • FTP服务器端软件Serv-U教程(5)
  • FTP服务器端软件Serv-U教程(6)
  • FTP服务器安全
  • 关于ftp服务程序中不安全因素研究
  • IIS建立FTP就真的那么弱吗

FTP服务器架设与维护阅读排行

  • FlashFTP教程
  • FTP服务器端软件Serv-U教程(1)
  • 菜鸟也能架设FTP服务器 1
  • FTP服务器端软件Serv-U教程(2)
  • FTP服务器端软件Serv-U教程(3)
  • FTP服务器端软件Serv-U教程(6)
  • FTP服务器端软件Serv-U教程(4)
  • FTP服务器快速架设全功略
  • FTP服务器安全
  • FTP服务器端软件Serv-U教程(5)

网络技术阅读总排行

  • 网络解惑:找回消失的本地连接
  • 教你如何通过路由器来控制上网
  • 网卡故障排除技巧详解
  • FlashFTP教程
  • 网上邻居十大经典应用技巧
  • 如何有效建立Win2000 VPN服务器
  • 经济实惠:组建P2P电影服务器
  • 查找局域网络中的故障技巧
  • 南阳信息港被黑案告破!
  • 小区宽带主要常见故障解决办法

广告位置

字母检索 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 回到顶部

关于我们 | 版权声明 | 免责条款 | 广告联系 | 软件发布 | 下载帮助 | 下载排行 | 网站地图 | 特别鸣谢 | 友情连接

copyright; 2005-2008 D9soft.com 第九软件网 版权所有