争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

用Linux架设FTP服务器(下)

时间:2023/12/24作者:未知来源:争怎路由网人气:

O_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



网络的神奇作用吸引着越来越多的用户加入其中,正因如此,网络的承受能力也面临着越来越严峻的考验―从硬件上、软件上、所用标准上......,各项技术都需要适时应势,对应发展,这正是网络迅速走向进步的催化剂。



关键词:用Linux架设FTP服务器(下)




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版