如果企业用户太多,创建太多的系统账户显然是不安全,这时候我们就需要虚拟账户,所谓虚拟用户就是,所有虚拟用户会统一映射为一个指定的系统普通账号:访问共享位置,即为此系统普通用户的家目录,当然每个虚拟用户也可被赋予不同的访问权限,通过匿名用户的权限控制参数进行指定。
这篇文章主要功能为Linux批量删除VSFTPD虚拟用户脚本,有需要的朋友可以参考下。(请结合Linux批量创建VSFTPD虚拟用户脚本此文章脚本使用)
文章源自小柒网-https://www.yangxingzhen.cn/1272.html
脚本内容如下:文章源自小柒网-https://www.yangxingzhen.cn/1272.html
#!/bin/bash
#Date:2018-5-20 13:14:00
#Author Blog:
# https://www.yangxingzhen.cn
# https://www.i7ti.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
文章源自小柒网-https://www.yangxingzhen.cn/1272.html文章源自小柒网-https://www.yangxingzhen.cn/1272.html 若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
继续阅读
Wechat
微信扫一扫,加我!
![weinxin](https://www.yangxingzhen.com/images/weixin.jpg)
我的微信
微信公众号
微信扫一扫,关注我!
![weinxin](https://www.yangxingzhen.com/images/weixingongzhonghao.png)
我的公众号
亲测,写的不错,感谢博主![:razz:](https://www.yangxingzhen.cn/wp-content/themes/begin/img/smilies/icon_razz.gif)