首页 > 服务器 > Ftp服务器 > 正文

基于UNIX平台FTP服务器的建立_Ftp服务器教程

2024-09-09 20:58:12
字体:
来源:转载
供稿:网友
目前很多企业单位正在构架自己的Intranet,Ftp服务器是其中的一个服务支持,有很多单位购置了基于UNIX 平台的计算机,为了在网上能够提供FTP服务支持,专门购置基于UNIX平台的FTP Server软件,其实在基于UNIX平台的计算机系统中,采取一定的技术方法,就可以建立自己的FTP Server,实现网上文件上下载服务,无须再购置专门的软件,和乐而不为之呢?下面就其建立过程阐述如下:

1.确定FTP Server的共享目录

为FTP Server建立一个FTP工作目录,在此设定为/home/ftp

2.编写FTP Server初始设置的Shell程序(setup)
用编辑工具(如vi)编写一个Shell程序,用于对系统进行设置。#!/bin/shcase $# in0) ftphome="`grep '^ftp:' /etc/passwd | cut -d: -f6`";;1) if [ "$1" = "start" ]; thenftphome="`grep '^ftp:' /etc/passwd | cut -d: -f6`"elseftphome=$1fi;;*) echo "Usage: $0 [anon-ftp-root]"exit 1;;esacif [ -z "${ftphome}" ]; thenecho "$0: ftphome must be non-null"exit 2fiif [ "${ftphome}" = "/" -o "${ftphome}" = "/usr" ]; thenecho "$0: ftphome must not be / or /usr"exit 2fiif [ ! -d ${ftphome} ]; thenmkdir ${ftphome}fiif [ ! -d ${ftphome}/usr/bin ]; thenmkdir -p ${ftphome}/usr/binficp /usr/bin/ls ${ftphome}/usr/binchmod 111 ${ftphome}/usr/bin/lschown root ${ftphome}/usr/binchmod 555 ${ftphome}/usr/binif [ -r ${ftphome}/bin ]; thenmv -f ${ftphome}/bin ${ftphome}/Obinfiln -s usr/bin ${ftphome}     if [ ! -d ${ftphome}/usr/lib ]; thenmkdir -p ${ftphome}/usr/libfiif [ ! -d ${ftphome}/etc ]; thenmkdir -p ${ftphome}/etcficp /usr/lib/ld.so /usr/lib/ld.so.1 ${ftphome}/usr/libfor lib in libc libdl libintl libw libnsl libsocket nss_nis nss_nisplus nss_dns nss_filesdocp /usr/lib/${lib}.so.1 ${ftphome}/usr/librm -f ${ftphome}/usr/lib/${lib}.soln -s ./${lib}.so.1 ${ftphome}/usr/lib/${lib}.sodonecp /usr/lib/straddr.so.2 ${ftphome}/usr/lib rm -f ${ftphome}/usr/lib/straddr.soln -s ./straddr.so.2 ${ftphome}/usr/lib/straddr.socp /etc/passwd /etc/group /etc/netconfig ${ftphome}/etcchmod 555 ${ftphome}/usr/lib/*chmod 444 ${ftphome}/etc/*chown root ${ftphome}/usr/lib ${ftphome}/etcchmod 555 ${ftphome}/usr/lib ${ftphome}/etcif [ ! -d ${ftphome}/dev ]; thenmkdir -p ${ftphome}/devfiprefix=/devices/pseudo/mm@0:for device in zeroline=`ls -l ${prefix}${device} | sed -e 's/,//'`major=`echo $line | awk '{print $5}'`minor=`echo $line | awk '{print $6}'`rm -f ${ftphome}/dev/${device}mknod ${ftphome}/dev/${device} c ${major} ${minor}doneprefix=/devices/pseudo/clone@0:for device in tcp udp ticotsorddoline=`ls -l ${prefix}${device} | sed -e 's/,//'`major=`echo $line | awk '{print $5}'`minor=`echo $line | awk '{print $6}'`rm -f ${ftphome}/dev/${device}mknod ${ftphome}/dev/${device} c ${major} ${minor}donechmod 666 ${ftphome}/dev/*chown root ${ftphome}/devchmod 555 ${ftphome}/dev#建立一个匿名FTP服务目录,并设立可读可写属性if [ ! -d ${ftphome}/pub ]; thenmkdir -p ${ftphome}/pubfichown ftp ${ftphome}/pubchmod 777 ${ftphome}/pub
3. 编辑/etc/passwd和/etc/shadow文件

设置匿名FTP帐号,按下面方法分别对/etc/passwd和/etc/shadow两个文件中增加如下数据项:

(1)在/etc/passwd文件中增加

ftp:x:30000:30000:Anonymous FTP:/home/ftp:/nosuchshell

(2)在/etc/shadow文件中增加

ftp:NP:6445::::::

4. 运行setup程序

在运行setup程序之前,将该文件设置成执行文件

#chmod +x setup

运行setup程序 #setup /home/ftp

以上步骤就完成了FTP服务器的建立,即可使用FTP服务器,可以用如explorer、netscape navigator等浏览器对Ftp服务器进行访问,进行下载和上载文件操作,使用非常方便。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表