分类:
2014-09-03 13:32:26
原文地址:【转载】Solaris9下安装vsftpd2.0.1 作者:东方蜘蛛
作者:wolfg
转自:
安装配置过程:
1.下载软件包
先取得wget,方便其他软件包的下载
# ftp
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
# gunzip vsftpd-2.0.1.tar.gz
# tar xvf vsftpd-2.0.1.tar
下载编译vsftpd必需的软件包
# wget
# gunzip make-3.80-sol9-sparc-local.gz
# pkgadd -d make-3.80-sol9-sparc-local
# wget
# gunzip libiconv-1.8-sol9-sparc-local.gz
# pkgadd -d libiconv-1.8-sol9-sparc-local
# wget
# 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 "$1" in start) /usr/local/bin/vsftpd & ;; stop) pkill vsftpd ;; *) echo "Usage: $0 { start | stop }" exit 1 ;; esac exit 0 |
代码: |
#! /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 " expect "*Password:" send "$password " expect eof |
代码: |
#!/sbin/sh # ftpuseradd usage() { echo "Usage: `basename $0` [-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=$1 PASSWORD=$2 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 |
代码: |
#!/sbin/sh # ftpuserdel usage() { echo "Usage: `basename $0` [-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=$1 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 |
代码: |
#!/sbin/sh # ftppasswd usage() { echo "Usage: `basename $0` username password" exit 1 } if [ $# -ne 2 ] then usage fi USERNAME=$1 PASSWORD=$2 setpasswd.exp $USERNAME $PASSWORD |