当前位置: 技术问答>linux和unix
各位大侠,怎么在solaris8下面配置ftp
来源: 互联网 发布时间:2015-03-05
本文导语: 提供相关的资料链接也好阿,请给小弟指条明路吧!!!! | 1、solaris下的用户都可以自由登陆。 2、匿名FTP服务器设置(例): 需要将下面的入口加到文件/etc/passwd中: ftp:x:30000:30000:Anonymous FTP:...
提供相关的资料链接也好阿,请给小弟指条明路吧!!!!
|
1、solaris下的用户都可以自由登陆。
2、匿名FTP服务器设置(例):
需要将下面的入口加到文件/etc/passwd中:
ftp:x:30000:30000:Anonymous FTP:/export/ftp:/nosuchshell
在这个例子中,用/export/ftp作为FTP服务器的根目录,并且使用一个不存在的文件/nosuchshell作为ftp用户的shell程序,这样可以防止ftp用户使用telnet登录。另外,还需要在文件/etc/shadow中加入下面的入口:
ftp:NP:6445::::::
建立匿名FTP服务器的shell程序:
#!/bin/sh
# script to setup anonymous ftp area
#
# handle the optional command line argument
case $# in
# 默认的匿名FTP服务器目录位置从/etc/passwd文件获取
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
# This script assumes that ftphome is neither / nor /usr so ...
if [ "${ftphome}" = "/" -o "${ftphome}" = "/usr" ]; then
echo "$0: ftphome must not be / or /usr"
exit 2
fi
# If ftphome does not exist but parent does, create ftphome
if [ ! -d ${ftphome} ]; then
# lack of -p below is intentional
mkdir ${ftphome}
fi
echo Setting up anonymous ftp area ${ftphome}
# Ensure that the /usr/bin directory exists
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
# Now set the ownership and modes to match the man page
chown root ${ftphome}/usr/bin
chmod 555 ${ftphome}/usr/bin
# this may not be the right thing to do
# but we need the bin -> usr/bin link
if [ -r ${ftphome}/bin ]; then
mv -f ${ftphome}/bin ${ftphome}/Obin
fi
ln -s usr/bin ${ftphome}/bin
# Ensure that the /usr/lib and /etc directories exist
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
# Copy timezone database
mkdir -p ${ftphome}/usr/share/lib/zoneinfo
(cd ${ftphome}/usr/share/lib/zoneinfo
(cd /usr/share/lib/zoneinfo; find . -print | cpio -o) | cpio -imdu
find . -print | xargs chmod 555
find . -print | xargs chown root
)
chmod 555 ${ftphome}/usr/lib/*
chmod 444 ${ftphome}/etc/*
# Now set the ownership and modes
chown root ${ftphome}/usr/lib ${ftphome}/etc
chmod 555 ${ftphome}/usr/lib ${ftphome}/etc
# Ensure that the /dev directory exists
if [ ! -d ${ftphome}/dev ]; then
mkdir -p ${ftphome}/dev
fi
# make device nodes. ticotsord and udp are necessary for
# 'ls' to resolve NIS names.
for device in zero tcp udp ticotsord
do
line=`ls -lL /dev/${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/*
## Now set the ownership and modes
chown root ${ftphome}/dev
chmod 555 ${ftphome}/dev
if [ ! -d ${ftphome}/pub ]; then
mkdir -p ${ftphome}/pub
fi
chown ftp ${ftphome}/pub
chmod 777 ${ftphome}/pub
2、匿名FTP服务器设置(例):
需要将下面的入口加到文件/etc/passwd中:
ftp:x:30000:30000:Anonymous FTP:/export/ftp:/nosuchshell
在这个例子中,用/export/ftp作为FTP服务器的根目录,并且使用一个不存在的文件/nosuchshell作为ftp用户的shell程序,这样可以防止ftp用户使用telnet登录。另外,还需要在文件/etc/shadow中加入下面的入口:
ftp:NP:6445::::::
建立匿名FTP服务器的shell程序:
#!/bin/sh
# script to setup anonymous ftp area
#
# handle the optional command line argument
case $# in
# 默认的匿名FTP服务器目录位置从/etc/passwd文件获取
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
# This script assumes that ftphome is neither / nor /usr so ...
if [ "${ftphome}" = "/" -o "${ftphome}" = "/usr" ]; then
echo "$0: ftphome must not be / or /usr"
exit 2
fi
# If ftphome does not exist but parent does, create ftphome
if [ ! -d ${ftphome} ]; then
# lack of -p below is intentional
mkdir ${ftphome}
fi
echo Setting up anonymous ftp area ${ftphome}
# Ensure that the /usr/bin directory exists
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
# Now set the ownership and modes to match the man page
chown root ${ftphome}/usr/bin
chmod 555 ${ftphome}/usr/bin
# this may not be the right thing to do
# but we need the bin -> usr/bin link
if [ -r ${ftphome}/bin ]; then
mv -f ${ftphome}/bin ${ftphome}/Obin
fi
ln -s usr/bin ${ftphome}/bin
# Ensure that the /usr/lib and /etc directories exist
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
# Copy timezone database
mkdir -p ${ftphome}/usr/share/lib/zoneinfo
(cd ${ftphome}/usr/share/lib/zoneinfo
(cd /usr/share/lib/zoneinfo; find . -print | cpio -o) | cpio -imdu
find . -print | xargs chmod 555
find . -print | xargs chown root
)
chmod 555 ${ftphome}/usr/lib/*
chmod 444 ${ftphome}/etc/*
# Now set the ownership and modes
chown root ${ftphome}/usr/lib ${ftphome}/etc
chmod 555 ${ftphome}/usr/lib ${ftphome}/etc
# Ensure that the /dev directory exists
if [ ! -d ${ftphome}/dev ]; then
mkdir -p ${ftphome}/dev
fi
# make device nodes. ticotsord and udp are necessary for
# 'ls' to resolve NIS names.
for device in zero tcp udp ticotsord
do
line=`ls -lL /dev/${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/*
## Now set the ownership and modes
chown root ${ftphome}/dev
chmod 555 ${ftphome}/dev
if [ ! -d ${ftphome}/pub ]; then
mkdir -p ${ftphome}/pub
fi
chown ftp ${ftphome}/pub
chmod 777 ${ftphome}/pub