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

  • 时间:
  • 浏览:0
  • 来源:1分快3平台-5分11选5投注平台_5分3D娱乐平台

目前什么都企业单位正在构架当事人的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/sh

case $# in

0) ftphome="`grep '^ftp:' /etc/passwd | cut -d: -f6`"

;;

1) if [ "$1" = "start" ]; then

ftphome="`grep '^ftp:' /etc/passwd | cut -d: -f6`"

else

ftphome=$1

fi

;;

*) echo "Usage: $0 [anon-ftp-root]"

exit 1

;;



esac

if [ -z "${ftphome}" ]; then

echo "$0: ftphome must be non-null"

exit 2

fi

if [ "${ftphome}" = "/" -o "${ftphome}" = "/usr" ]; then

echo "$0: ftphome must not be / or /usr"

exit 2

fi

if [ ! -d ${ftphome} ]; then

mkdir ${ftphome}

fi

if [ ! -d ${ftphome}/usr/bin ]; then

mkdir -p ${ftphome}/usr/bin

fi

cp /usr/bin/ls ${ftphome}/usr/bin

chmod 111 ${ftphome}/usr/bin/ls

chown root ${ftphome}/usr/bin

chmod 555 ${ftphome}/usr/bin

if [ -r ${ftphome}/bin ]; then

mv -f ${ftphome}/bin ${ftphome}/Obin

fi

ln -s usr/bin ${ftphome}

if [ ! -d ${ftphome}/usr/lib ]; then

mkdir -p ${ftphome}/usr/lib

fi



if [ ! -d ${ftphome}/etc ]; then

mkdir -p ${ftphome}/etc

fi

cp /usr/lib/ld.so /usr/lib/ld.so.1 ${ftphome}/usr/lib

for lib in libc libdl libintl libw libnsl libsocket \

nss_nis nss_nisplus nss_dns nss_files

do

cp /usr/lib/${lib}.so.1 ${ftphome}/usr/lib

rm -f ${ftphome}/usr/lib/${lib}.so

ln -s ./${lib}.so.1 ${ftphome}/usr/lib/${lib}.so

done

cp /usr/lib/straddr.so.2 ${ftphome}/usr/lib

rm -f ${ftphome}/usr/lib/straddr.so



ln -s ./straddr.so.2 ${ftphome}/usr/lib/straddr.so

cp /etc/passwd /etc/group /etc/netconfig ${ftphome}/etc

chmod 555 ${ftphome}/usr/lib/*

chmod 444 ${ftphome}/etc/*

chown root ${ftphome}/usr/lib ${ftphome}/etc

chmod 555 ${ftphome}/usr/lib ${ftphome}/etc

if [ ! -d ${ftphome}/dev ]; then

mkdir -p ${ftphome}/dev

fi

prefix="/devices/pseudo/mm@0:"

for device in zero

line=`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}

done



prefix="/devices/pseudo/clone@0:"

for device in tcp udp ticotsord

do

line=`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}

done

chmod 666 ${ftphome}/dev/*

chown root ${ftphome}/dev

chmod 555 ${ftphome}/dev

#建立有有好几个 匿名FTP服务目录,并设立可读可写属性

if [ ! -d ${ftphome}/pub ]; then

mkdir -p ${ftphome}/pub

fi

chown ftp ${ftphome}/pub

chmod 777 ${ftphome}/pub

3.         编辑/etc/passwd和/etc/shadow文件

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

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

ftp:x:3000:3000: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服务器进行访问,进行下载和上载文件操作,使用非常方便。