WEB开发网
开发学院服务器FTP服务器 linux下ftp服务器架设 阅读

linux下ftp服务器架设

 2007-07-13 16:19:54 来源:WEB开发网   
核心提示:配置“/etc/ftpconversions”文件“/etc/ftpconversions”是用来控制当传输文件的时候是否进行压缩,创建“ftpconversions”文件(touch /etc/ftpconversions),linux下ftp服

配置“/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]# chmod 600 /etc/ftpconversions

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

创建“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)

可以看到现在有一个用户登录(最多可以有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.

上一页  1 2 3 4 5  下一页

Tags:linux ftp 服务器

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接