vsftpd服务器批量创建用户之pasv模式脚本-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 2090549
  • 博文数量: 195
  • 博客积分: 4378
  • 博客等级: 上校
  • 技术积分: 4046
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-09 11:37
个人简介

白天和黑夜只交替没交换无法想像对方的世界

文章分类

全部博文(195)

文章存档

2014年(3)

2013年(20)

2012年(18)

2011年(107)

2010年(17)

2009年(5)

2008年(20)

2007年(5)

相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: python/ruby

2011-05-31 15:14:43

最近需要搭建vsftpd文档服务器,为了节省时间,就编写了如下两个脚本,一个是针对32位系统的,另一个是针对64位的系统的,以后使用的时候方便。
 
脚本一:
 
#!/bin/sh
#write by kevin
#auto_create_vsftpd_priv_32
#date 2011-05-04

###########make install vsftpd-pam#################
yum -y install db4 db4-utils db4-devel
wget
tar xfz vsftpd-2.3.4.tar.gz
cd vsftpd-2.3.4
make clean
sed -i 's/undef/define/g' builddefs.h
make
install -m 755 vsftpd /usr/local/sbin/vsftpd-pam
install -m 644 vsftpd.8 /usr/share/man/man8
install -m 644 vsftpd.conf.5 /usr/share/man/man5
install -m 644 vsftpd.conf /etc/vsftpd-pam.conf
###################################################
set -x
if [ "$i" == "" ];then
length=20
else
length=$i
fi
############configure of login###########
cat>>/home/logins.txt<ftpuser

ftpadmin

eof
#########################################
echo -e "===============================================\n\n"
echo -e "the logins.txt is configured ok n\n"
echo -e "===============================================\n\n"
 
ftp_pwd_file="/data/path/auto_change_pwd.txt"
mkdir -p /data/path
touch $ftp_pwd_file
chmod 600 $ftp_pwd_file
ip_last=`/sbin/ifconfig eth0|grep "inet addr"|awk '{print $2}'|awk -f ":" '{print $2}'|cut -d \. -f3-4`
update_time=`date "%y-%m-%d %h:%m:%s"`
echo "$ip_last:" >$ftp_pwd_file
echo "update_time: $update_time" >> $ftp_pwd_file
echo "====================================================" >>$ftp_pwd_file
login_file=/home/logins.txt
sed -i '$d' $login_file
ftp_pwd=`tr -dc _a-z-a-z#$%^*-0-9 echo $ftp_pwd >> $login_file
db_load -t -t hash -f /home/logins.txt /etc/vsftpd_login.db
chmod 600 /etc/vsftpd_login.db
for i in `sed -n '3p' $login_file`
do
if [ $? == 0 ];then
echo -e "$i\t\t\t${ftp_pwd}">> $ftp_pwd_file
echo "==================================================" >> $ftp_pwd_file
else
echo -e "change passwd for $i error" >> $ftp_pwd_file
fi
done
cat>> /etc/pam.d/ftp<auth required /lib/security/pam_userdb.so db=/etc/vsftpd_login
account required /lib/security/pam_userdb.so db=/etc/vsftpd_login
eof
useradd -d /home/vsftpd -s /sbin/nologin vsftpd
mkdir /etc/vsftpd_user_conf/
for n in `sed -n 'p;n' $login_file`
do
mkdir /home/vsftpd/$n
cat >>/etc/vsftpd_user_conf/$n<local_root=/home/vsftpd/$n
write_enable=yes
anon_world_readable_only=no
anon_upload_enable=yes
anon_mkdir_write_enable=yes
anon_other_write_enable=yes
eof
chmod -r 700 /home/vsftpd/$n
chown -r vsftpd.vsftpd /home/vsftpd/$n
done
cat >>/etc/vsftpd-pam.conf<listen=yes
listen_port=6006
connect_from_port_20=no
pasv_max_port=6000
pasv_min_port=5000
tcp_wrappers=yes
anonymous_enable=no
local_enable=yes
write_enable=no
anon_upload_enable=no
anon_mkdir_write_enable=no
anon_other_write_enable=no
chroot_local_user=no
dirmessage_enable=yes
message_file=/etc/.message
chroot_list_enable=yes
chroot_list_file=/etc/vsftpd.chroot_list
guest_enable=yes
guest_username=vsftpd
virtual_use_local_privs=yes
pasv_enable=yes
local_max_rate=2097152
#max_clients=50
max_clients=100
max_per_ip=2
anon_world_readable_only=no
user_config_dir=/etc/vsftpd_user_conf
#user_acl_list
#userlist_file=/etc/vsftpd.user_list
#userlist_enable=yes
#userlist_deny=no
xferlog_enable=yes
xferlog_file=/var/log/xferlog
dual_log_enable=yes
vsftpd_log_file=/var/log/vsftpd.log
use_localtime=yes
eof
cat >>/etc/.message<welcome to teasure's ftp website.you can upload and download things that you like!
eof
cat >>/etc/vsftpd.chroot_list<ftpuser
ftpadmin
eof
#start vsftpd
/usr/local/sbin/vsftpd-pam /etc/vsftpd-pam.conf &
echo -e "================================================"
echo -e "service vsfptd-pam is start\n\n"
echo -e "================================================"
exit 0
 

 
****************************************************************************
 
 
 
脚本二:
#!/bin/sh
#write by kevin
#auto_create_vsftpd_priv_64
#date 2011-05-04
###########make install vsftpd-pam#################
yum -y install db4 db4-utils db4-devel
wget
tar xfz vsftpd-2.3.4.tar.gz
cd vsftpd-2.3.4
make clean
sed -i 's/undef/define/g' builddefs.h
sed -i 's#/lib/#lib64/#g' ./vsf_findlibs.sh
make
install -m 755 vsftpd /usr/local/sbin/vsftpd-pam
install -m 644 vsftpd.8 /usr/share/man/man8
install -m 644 vsftpd.conf.5 /usr/share/man/man5
install -m 644 vsftpd.conf /etc/vsftpd-pam.conf
###################################################
#set -x
if [ "$i" == "" ];then
length=20
else
length=$i
fi
############configure of login###########
cat>/home/.logins.txt<ftpuser

ftpadmin

eof
#########################################
echo -e "===============================================\n\n"
echo -e "the logins.txt is configured ok \n\n"
echo -e "===============================================\n\n"
 
ftp_pwd_file="/data/path/auto_change_pwd.txt"
mkdir -p /data/path
touch $ftp_pwd_file
chmod 600 $ftp_pwd_file
ip_last=`/sbin/ifconfig eth0|grep "inet addr"|awk '{print $2}'|awk -f ":" '{print $2}'|cut -d \. -f3-4`
update_time=`date "%y-%m-%d %h:%m:%s"`
echo "$ip_last:" >$ftp_pwd_file
echo "update_time: $update_time" >> $ftp_pwd_file
echo "====================================================" >>$ftp_pwd_file
login_file=/home/.logins.txt
sed -i '$d' $login_file
ftp_pwd=`tr -dc _a-z-a-z#$%^*-0-9 echo $ftp_pwd >> $login_file
db_load -t -t hash -f /home/.logins.txt /etc/vsftpd_login.db
chmod 600 /etc/vsftpd_login.db
for i in `sed -n '3p' $login_file`
do
if [ $? == 0 ];then
echo -e "$i\t\t\t${ftp_pwd}">> $ftp_pwd_file
echo "==================================================" >> $ftp_pwd_file
else
echo -e "change passwd for $i error" >> $ftp_pwd_file
fi
done
cat> /etc/pam.d/ftp<auth required /lib64/security/pam_userdb.so db=/etc/vsftpd_login
account required /lib64/security/pam_userdb.so db=/etc/vsftpd_login
eof
useradd -d /home/vsftpd -s /sbin/nologin vsftpd
mkdir /etc/vsftpd_user_conf/
for n in `sed -n 'p;n' $login_file`
do
mkdir /home/vsftpd/$n
cat >/etc/vsftpd_user_conf/$n<local_root=/data/.vsftpd/$n
write_enable=no
anon_world_readable_only=no
anon_upload_enable=yes
anon_mkdir_write_enable=yes
anon_other_write_enable=yes
eof
chmod -r 700 /data/.vsftpd/$n
chown -r .vsftpd /data/.vsftpd/$n
chgrp -r .vsftpd /data/.vsftpd/$n
done
cat >/etc/vsftpd-pam.conf<listen=yes
#listen_port=21
listen_port=6006
#ftp_data_port=8080
connect_from_port_20=no
pasv_max_port=6000
pasv_min_port=5000
tcp_wrappers=yes
anonymous_enable=no
local_enable=yes
write_enable=no
anon_upload_enable=no
anon_mkdir_write_enable=no
anon_other_write_enable=no
chroot_local_user=no
dirmessage_enable=yes
message_file=/etc/.message
chroot_list_enable=yes
chroot_list_file=/etc/vsftpd.chroot_list
guest_enable=yes
guest_username=.vsftpd
virtual_use_local_privs=yes
pasv_enable=yes
local_max_rate=2097152
max_clients=100
max_per_ip=3
anon_world_readable_only=no
user_config_dir=/etc/vsftpd_user_conf
#user_acl_list
#userlist_file=/etc/vsftpd.user_list
#userlist_enable=yes
#userlist_deny=no
xferlog_enable=yes
xferlog_file=/var/log/xferlog
dual_log_enable=yes
vsftpd_log_file=/var/log/vsftpd.log
use_localtime=yes
eof
cat >>/etc/.message<welcome to teasure's ftp website.you can upload and download things that you like!
eof
cat >/etc/vsftpd.chroot_list<ftpuser
ftpadmin
eof
#start vsftpd
/usr/local/sbin/vsftpd-pam /etc/vsftpd-pam.conf &
echo -e "================================================\n\n"
echo -e "service vsfptd-pam is start\n\n"
echo -e "================================================"
exit 0
 
****************************************************************************************
 
 
阅读(5111) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图