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 $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
ftpuserdel
代码: #!/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
ftppasswd
代码: #!/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
6.参考:
Manpage of VSFTPD.CONF,http://vsftpd.beasts.org/vsftpd_conf.html
Freeware for Solaris, http://www.sunfreeware.com/
在SOLARIS上编译安装VSFTPD, [url=http://www.pccode.net].net/forum/viewtopic.php?t=344943"http://bbs.chinaunix.net/forum/viewtopic.php?t=344943
(T111)