找回密码
 马上注册

扫一扫,访问微社区

搜索
热搜: mestrenova
查看: 4223|回复: 5

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

[复制链接]
发表于 2006-12-1 20:26:16 | 显示全部楼层 |阅读模式
 目前很多企业单位正在构架自己的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


;;

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


;;

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: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服务器,可以用如explorernetscape navigator等浏览器对FTP服务器进行访问,进行下载和上载文件操作,使用非常方便。

回复

使用道具 举报

发表于 2008-3-5 21:54:58 | 显示全部楼层
haha 呵呵,其实男女都一样的,最新新闻 谁都想在家舒舒服服的看电视,上网啥的 肯定是家庭需要哎,业主最新热门帖子大家相互体谅是主要的,把握尺度 钱很重要但不是主要的
回复 支持 反对

使用道具 举报

发表于 2008-4-10 23:04:54 | 显示全部楼层
完全不明白  支持一下吧
回复 支持 反对

使用道具 举报

发表于 2009-8-3 02:15:07 | 显示全部楼层
好贴子要顶叻,这么好的贴子为什么没人顶呢?支持一个! ------------------------------------------------------------------------------------------------------------------------------------ 我常用dhl,dhl快递 ,tnt快递。速度快,有保障。
回复 支持 反对

使用道具 举报

发表于 2011-2-16 08:31:59 | 显示全部楼层
Thanks! That''s great! ____________________ PPP01188 PPP01189 PPP01190 PPP01191 PPP01192 public records ,
回复 支持 反对

使用道具 举报

发表于 2011-4-18 18:18:38 | 显示全部楼层
Thanks for this valuable thread! ____________________ PPP02632 PPP02633 PPP02634 PPP02635 PPP02636 public records search ,
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

Archiver|手机版|中国核磁共振论坛

GMT+8, 2024-11-26 15:56

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表