用Linux架设FTP服务器(5)

2009-05-13 00:54:16来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折


配置“/etc/ftphosts”文件
“/etc/ftphosts”文件为每一个用户建立规则,指定允许用户从某个主机登录ftp服务器,或者不允许用户从某个主机登录ftp服务器。
创建“ftphosts”文件(touch/etc/ftphosts),加入下面这几行:
#Examplehostaccessfile
#
#Everythingaftera‘#‘istreatedascomment,
#emptylinesareignored
allowftpadmin208.164.186.1208.164.186.2208.164.186.4
把文件的权限改为600:
[root@deep]#chmod600/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]#chmod600/etc/ftpusers
配置“/etc/ftpconversions”文件
“/etc/ftpconversions”是用来控制当传输文件的时候是否进行压缩。
创建“ftpconversions”文件(touch/etc/ftpconversions),在文件中加入:
:.Z:::/bin/compress-d-c%s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
:::.Z:/bin/compress-c%s:T_REG:O_COMPRESS:COMPRESS
:.gz:::/bin/gzip-cd%s:T_REG|T_ASCII:O_UNCOMPRESS:GUNZIP
:::.gz:/bin/gzip-9-c%s:T_REG:O_COMPRESS:GZIP
:::.tar:/bin/tar-c-f-%s:T_REG|T_DIR:O_TAR:TAR
:::.tar.Z:/bin/tar-c-Z-f-%s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
:::.tar.gz:/bin/tar-c-z-f-%s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+GZIP
:::.crc:/bin/cksum%s:T_REG::CKSUM
:::.md5:/bin/md5sum%s:T_REG::MD5SUM

把文件的属性改为600:
[root@deep]#chmod600/etc/ftpconversions
配置“/etc/pam.d/ftp”文件
配置“/etc/pam.d/ftp”文件使其支持PAM安全验证。
创建“ftp”文件(touch/etc/pam.d/ftp)并加入:
#%PAM-1.0
authrequired/lib/security/pam_listfile.soitem=usersense=denyfile=/etc/ftpusersonerr=succeed
authrequired/lib/security/pam_pwdb.soshadownullok
authrequired/lib/security/pam_shells.so
accountrequired/lib/security/pam_pwdb.so
sessionrequired/lib/security/pam_pwdb.so
配置“/etc/logrotate.d/ftpd”文件
配置“/etc/logrotate.d/ftpd”文件使得日志文件每周自动循环更新。
创建“ftpd”文件(touch/etc/logrorate.d/ftpd)并加入:
/var/log/xferlog{
#ftpddoesn‘thandleSIGHUPproperly
nocompress
}
配置ftp使其使用inetd超级服务器(用于实现tcp-wrappers)
tcp-wrappers用来启动和中止ftpd服务。当inetd执行的时候,它会从默认为“/etc/inetd.conf”的配置文件读入配置信息。配置文件中每一行中的项用TAB或空格隔开。
编辑inetd.conf文件(vi/etc/inetd.conf),加入并验证是否存在下面这一行:ftpstreamtcpnowaitroot/usr/sbin/tcpdin.ftpd-l-a
注意:更新完“inetd.conf”文件之后要发给inetd一个SIGNUP信号,运行下面的命令:
[root@deep/root]#killall-HUPinetd
编辑“hosts.allow”文件(vi/etc/hosts.allow)加入这一行:
in.ftpd:192.168.1.4win.openarch.com
这表示IP地址为“192.168.1.4”并且主机名为“win.openarch.com”的计算机允许访问ftp服务器。

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:用Linux架设FTP服务器(4)

下一篇:用Linux架设FTP服务器(6)