如果企业用户太多,创建太多的系统账户显然是不安全,这时候我们就需要虚拟账户,所谓虚拟用户就是,所有虚拟用户会统一映射为一个指定的系统普通账号:访问共享位置,即为此系统普通用户的家目录,当然每个虚拟用户也可被赋予不同的访问权限,通过匿名用户的权限控制参数进行指定。
这篇文章主要功能为Linux批量删除VSFTPD虚拟用户脚本,有需要的朋友可以参考下。(请结合Linux批量创建VSFTPD虚拟用户脚本此文章脚本使用)
脚本内容如下:
#!/bin/bash
#Date:2018-5-20 13:14:00
#Author Blog:
# https://www.yangxingzhen.com
# https://www.yangxingzhen.cn
#Author WeChat:
# 微信公众号:小柒博客
#Author mirrors site:
# https://mirrors.yangxingzhen.com
#About the Author
# BY:YangXingZhen
# Mail:xingzhen.yang@yangxingzhen.com
# QQ:675583110
#Batch deletion of vsftpd virtual users(支持删除单个用户跟多个用户)
#This script applies to Centos 6.x and Centos 7.x
FTP_DIR="/etc/vsftpd"
USER="$\*"
if \[ $# -eq 0 \];then
echo -e "\\033\[33m Please enter the username that needs to be deleted \\033\[0m"
echo -e "\\033\[33m Usage: sh $0 {admin\|admin123\|help} \\033\[0m"
exit 0
elif \[\[ ${USER} == "help" \]\];then
echo -e "\\033\[33m Please enter the username that needs to be deleted \\033\[0m"
echo -e "\\033\[33m Usage: sh $0 {admin\|admin123\|help} \\033\[0m"
exit 0
fi
for i in `echo ${USER}`
do
grep -qwc "$i" ${FTP_DIR}/ftpusers.txt
if \[ $? -eq 0 \];then
sed -i "/\^${i}$/,+1"d ${FTP_DIR}/ftpusers.txt
sed -i "/\^${i}$/"d ${FTP_DIR}/vsftpd.chroot_list
rm -rf /home/ftpuser/$i
rm -rf ${FTP_DIR}/vsftpd_user_conf/$i
rm -rf ${FTP_DIR}/vsftpd_login.db
db_load -T -t hash -f ${FTP_DIR}/ftpusers.txt ${FTP_DIR}/vsftpd_login.db
chmod 700 ${FTP_DIR}/vsftpd_login.db
echo "`date +%Y/%m/%d-%T` $i Delete success" \>\> ${FTP_DIR}/delete_list.txt
echo -e "\\033\[32m User $i deleting success,Please check the record file \>\> ${FTP_DIR}/delete_list.txt \\033\[0m"
else
echo -e "\\033\[32m User $i deleting Fail,This user does not exist \\033\[0m"
fi
done
继续阅读
历史上的今天
5 月
20