【转载】Solaris9下安装vsftpd2.0.1

发表于:2007-05-26来源:作者:点击数: 标签:
作者:wolfg 转自: http://bbs.chinaunix.net/forum/viewtopic.php?t=505936 安装配置过程: 1. 下载软件包 先取得wget,方便其他软件包的下载 # ftp www.sunfreeware.com ftp cd pub/freeware/sparc/9 ftp get wget-1.9.1-sol9-sparc-local.gz ftp bye 安装w

作者:wolfg

转自:http://bbs.chinaunix.net/forum/viewtopic.php?t=505936

安装配置过程:

1.下载软件包

先取得wget,方便其他软件包的下载

# ftp
www.sunfreeware.com
ftp > cd pub/freeware/sparc/9
ftp > get wget-1.9.1-sol9-sparc-local.gz
ftp > bye

安装wget
# gunzip wget-1.9.1-sol9-sparc-local.gz
# pkgadd -d wget-1.9.1-sol9-sparc-local

下载vsftpd
# wget
ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.0.1.tar.gz
# gunzip vsftpd-2.0.1.tar.gz
# tar xvf vsftpd-2.0.1.tar

下载编译vsftpd必需的软件包
# wget
ftp://ftp.sunfreeware.com/pub/freeware/sparc/9/make-3.80-sol9-sparc-local.gz
# gunzip make-3.80-sol9-sparc-local.gz
# pkgadd -d make-3.80-sol9-sparc-local

# wget
ftp://mirror.sprintlink.net/sunfreeware.com/pub/freeware/sparc/9/libiconv-1.8-sol9-sparc-local.gz
# gunzip libiconv-1.8-sol9-sparc-local.gz
# pkgadd -d libiconv-1.8-sol9-sparc-local

# wget
clearcase/" target="_blank" >cc_small-3.3.2-sol9-sparc-local.gz" target="_blank">ftp://mirror.sprintlink.net/sunfreeware.com/pub/freeware/sparc/9/gcc_small-3.3.2-sol9-sparc-local.gz
# gunzip gcc_small-3.3.2-sol9-sparc-local.gz
# pkgadd -d gcc_small-3.3.2-sol9-sparc-local

2.编译 安装vsftpd
# cd vsftpd-2.0.1
# make

# mkdir /usr/share/empty
# cp vsftpd /usr/local/bin/vsftpd
# cp vsftpd.conf.5 /usr/local/man/man5
# cp vsftpd.8 /usr/local/man/man8

# cp vsftpd.conf /etc

3.配置vsftpd
建ftp目录和ftp帐号,所有ftp登录用户都映射到此帐号
# mkdir /data/ftp
# groupadd ftp
# useradd -d /data/ftp -g ftp -s /bin/false ftp
# chown ftp:ftp /data/ftp

# echo "ftp" >> /etc/vsftpd.chroot_list

建立放置每个ftp用户的独自的配置文件的目录
# mkdir /etc/vsftpd

修改/etc/vsftpd.conf
# vi /etc/vsftpd.conf

anonymous_enable=NO
local_enable=YES

write_enable=NO

local_umask=022
anon_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
idle_session_timeout=600
data_connection_timeout=120
ftpd_banner=Welcome!
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
user_config_dir=/etc/vsftpd

ls_recurse_enable=NO
hide_ids=YES
userlist_enable=YES
userlist_deny=NO
userlist_file=/etc/vsftpd.user_list
guest_enable=YES
guest_username=ftp

max_clients=50
max_per_ip=2
pasv_min_port=55000
pasv_max_port=55100
listen=YES
local_root=/data/ftp/$USER # 每个用户都有自己的ftp主目录
user_sub_token=$USER


建启动脚本
# vi /etc/rc3.d/S83vsftpd

代码:

#!/sbin/sh
case "" in
start)
       /usr/local/bin/vsftpd &
;;
stop)
       pkill vsftpd
;;
*)
       echo "Usage: { start | stop }"
       exit 1
;;
esac
exit 0


4.用户管理

手工添加用户
# useradd -d /dev/null -g ftp -s /bin/false test

设置密码
# passwd test

在/etc/vsftpd/下添加一个与用户名相同名字的文件
# vi /etc/vsftpd/test
若只允许下载,则添加如下内容
anon_world_readable_only=no
anon_max_rate=512000

若允许上传,则添加如下内容
anon_world_readable_only=NO  
write_enable=YES  
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
anon_max_rate=1024000

追加新增的用户test到/etc/vsftpd.user_list文件
# echo "test">> /etc/vsftpd.user_list

建立test用户的ftp主目录
# mkdir /data/ftp/test
# chown ftp:ftp /data/ftp/test

5.用户管理脚本
方便添加、删除用户、修改用户密码

安装脚本运行需要的软件包:
# wget  ftp://mirror.sprintlink.net/sunfreeware.com/pub/freeware/sparc/9/tcl-8.4.6-sol9-sparc-local.gz
# gunzip tcl-8.4.6-sol9-sparc-local.gz
# pkgadd -d tcl-8.4.6-sol9-sparc-local

# wget
ftp://mirror.sprintlink.net/sunfreeware.com/pub/freeware/sparc/9/tk-8.4.6-sol9-sparc-local.gz
# gunzip tk-8.4.6-sol9-sparc-local.gz
# pkgadd -d tk-8.4.6-sol9-sparc-local

# wget
ftp://mirror.sprintlink.net/sunfreeware.com/pub/freeware/sparc/9/expect-5.40-sol9-sparc-local.gz
# gunzip expect-5.40-sol9-sparc-local.gz
# pkgadd -d expect-5.40-sol9-sparc-local

setpasswd.exp
代码:

#! /usr/local/bin/expect -f
#username is passed as 1st arg,password as 2nd
set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect "*Password:"
send "$password\r"
expect "*Password:"
send "$password\r"
expect eof


ftpuseradd
代码:

#!/sbin/sh
# ftpuseradd
usage()
{
echo "Usage: `basename ` [-w] [-m maxrate] username password"
exit 1
}
WRITABLE="no" # can't upload
MAXRATE="64000" # default max rate is 64Kb
OPT="no"

while getopts :wm: OPTION
do
 case $OPTION in
 w) WRITABLE="yes"
   OPT="yes"
   ;;
 m) MAXRATE=$OPTARG
   OPT="yes"
   ;;
 \?) usage
   ;;
 esac
done

shift `expr $OPTIND - 1`

if [ $# -ne 2 ]
then
 usage
fi

USERNAME=
PASSWORD=

useradd -d /dev/null -g ftp -s /bin/false $USERNAME

if [ $? -eq 0 ]
then
 setpasswd.exp $USERNAME $PASSWORD > /dev/null

 echo "anon_world_readable_only=NO" > /etc/vsftpd/$USERNAME
 echo "anon_max_rate=$MAXRATE" >> /etc/vsftpd/$USERNAME

 if [ "$WRITABLE" = "yes" ]
 then
   echo "write_enable=YES" >> /etc/vsftpd/$USERNAME
   echo "anon_upload_enable=YES" >> /etc/vsftpd/$USERNAME
   echo "anon_mkdir_write_enable=YES" >> /etc/vsftpd/$USERNAME
   echo "anon_other_write_enable=YES" >> /etc/vsftpd/$USERNAME
 fi
 
 echo "$USERNAME" >> /etc/vsftpd.user_list
 
 mkdir /data/ftp/$USERNAME
 chown ftp:ftp /data/ftp/$USERNAME
fi


ftpuserdel
代码:

#!/sbin/sh
# ftpuserdel
usage()
{
echo "Usage: `basename ` [-r] username"
exit 1
}
REMOVEDIR="no"

while getopts :r OPTION
do
 case $OPTION in
 r) REMOVEDIR="yes"
   ;;
 \?) usage
   ;;
 esac
done

shift `expr $OPTIND - 1`

if [ $# -ne 1 ]
then
 usage
fi

USERNAME=

userdel $USERNAME
if [ $? -eq 0 ]
then
 if [ -f /etc/vsftpd.user_list ]
 then
   cat /etc/vsftpd.user_list | sed "/^$USERNAME$/d" | sed '1,$ w /etc/vsftpd.user_list' > /dev/null
 fi
 if [ -f /etc/vsftpd/$USERNAME ]
 then
   rm -f /etc/vsftpd/$USERNAME > /dev/null
 fi
 if [ -d /data/ftp/$USERNAME -a "$REMOVEDIR" = "yes" ]
 then
   rm -rf /data/ftp/$USERNAME > /dev/null
 fi
fi


ftppasswd
代码:

#!/sbin/sh
# ftppasswd
usage()
{
echo "Usage: `basename ` username password"
exit 1
}
if [ $# -ne 2 ]
then
 usage
fi

USERNAME=
PASSWORD=

setpasswd.exp $USERNAME $PASSWORD


6.参考:
Manpage of VSFTPD.CONF,
http://vsftpd.beasts.org/vsftpd_conf.html
Freeware for Solaris,
http://www.sunfreeware.com/
在SOLARIS上编译安装VSFTPD,
http://bbs.chinaunix.net/forum/viewtopic.php?t=344943

原文转自:http://www.ltesting.net