评论

收藏

[Linux] Linux vsftp vuer虚拟用户的创建批量脚本

服务系统 服务系统 发布于:2022-09-15 20:05 | 阅读数:241 | 评论:0

#!/bin/sh
#Edit by mengbing
#DATE:20220914
#Usage:sh adduser_vuser.sh
echo -n "Enter the accout's  number -> "
read number
expr $number + 10 > /dev/null 2>&1
status=$?

while  [ "$status"  !=  "0" ]
do
  echo -n " You must input a number: "
  read number
  expr $number + 10 > /dev/null 2>&1
  status=$?
done

counter=0
while [ $counter -lt $number ]
do
  serial=`expr $counter + 1`
  echo -n  " Enter the $serial  account name ->  "
  read NAME
  echo -n  " Enter the $serial  account passwd ->  "
  read PASSWD
  echo -n  " Retype  Enter the $serial  account passwd ->  "
  read PASSWD2
if [ $PASSWD = $PASSWD2 ]; then
  echo $NAME >> /etc/vsftpd/ftpvuser
  echo $PASSWD >> /etc/vsftpd/ftpvuser
  db_load -T -t hash -f /etc/vsftpd/ftpvuser /etc/vsftpd/ftpvuser.db
  cp /etc/vsftpd/vuser_dir/4MCT  /etc/vsftpd/vuser_dir/$NAME
  echo "Congratulation,The account $NAME is created success."
  echo "Congratulation,The account $NAME is created success.The information is below.
USER:$NAME
PASSWORD:$PASSWD
Please Remember it.THX" |mail -s "DFS NEW ACCOUNT" mengbing@xx.com
else
  echo "Sorry, passwords do not match. The account $NAME is not created."
  exit
fi
  counter=`expr $counter + 1`
done