centos6一键安装vsftpd脚本

2024-09-09 04:58

本文主要是介绍centos6一键安装vsftpd脚本,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

centos6一键安装vsftpd脚本

手动安装vsftpd参考教程:Centos下安装Vsftpd的图文教程

vsftpd脚本功能:

1.安装 (命令执行:sh xxx.sh)2.添加ftp用户 (命令执行:sh xxx.sh add)3.卸载vsftpd (命令执行:sh xxx.sh uninstall)

测试环境:centos6 x64 centos6 x86(测试centos7以上无法安装)

20170428155039

vsftpd shell脚本代码:

#!/bin/bash
Stack=$1
if [ "${Stack}" = "" ]; thenStack="install"
elseStack=$1
fi
install_vsftp()
{echo "#######################"echo -e "\033[33mUsage: $0 {install|add|uninstall}\033[0m"echo -e "\033[33msh $0 (default:install)\033[0m"echo -e "\033[33msh $0 add (Add FTP user)\033[0m"echo -e "\033[33msh $0 uninstall (Uninstall FTP)\033[0m"echo "#######################"A=`head -c 500 /dev/urandom | tr -dc a-zA-Z | tr [a-z] [A-Z]|head -c 1`B=`head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 6`C=`echo $RANDOM|cut -c 2`rpm -q vsftpdif [ "$?" -eq "0" ]; thenecho "You have to install VSFTPD!"elsenetstat -ntulp |grep -w 21if [ "$?" -eq "0" ]; thenecho "Other FTP is already installed"elseread -p "The FTP access directory(default:/home): " directoryif [ "${directory}" != "" ]; thendirectorys="${directory}"elsedirectorys="/home"firead -p "Please enter the FTP user: " ftp_userread -p "Enter the FTP password(default:$A$B$C): " ftp_passif [ "${ftp_pass}" != "" ]; thenftp_passa="${ftp_pass}"elseftp_passa="$A$B$C"fiyum -y install vsftpdif [ "$?" -eq "0" ]; thenif [ -d ${directorys} ]; thenchmod -R 777 ${directorys}fiuseradd -d ${directorys} -g ftp -s /sbin/nologin ${ftp_user}echo "${ftp_passa}" | passwd --stdin ${ftp_user} > /dev/nullsed -i 's/^anonymous_enable=YES/anonymous_enable=NO/g' /etc/vsftpd/vsftpd.confsed -i 's/^#chroot_local_user=YES/chroot_local_user=YES/g' /etc/vsftpd/vsftpd.confsed -i 's/^#chroot_list_enable=YES/chroot_list_enable=YES/g' /etc/vsftpd/vsftpd.confecho "userdel ${ftp_user}" >> /etc/vsftpd/user_list.shecho "" > /etc/vsftpd/chroot_listchkconfig vsftpd onservice vsftpd restartecho "###################################"echo "FTP user:${ftp_user}"echo "Ftp password:${ftp_passa}"echo "The FTP directory:${directorys}"echo "-----------------------------------"elseecho "VSFTPD installation failed!"fififi
}
add_ftp()
{A=`head -c 500 /dev/urandom | tr -dc a-zA-Z | tr [a-z] [A-Z]|head -c 1`B=`head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 6`C=`echo $RANDOM|cut -c 2`read -p "The FTP access directory(Such as:/home): " directoryif [ "${directory}" != "" ]; thendirectorys="${directory}"elsedirectorys="/home"firead -p "Please enter the FTP user: " ftp_userread -p "Enter the FTP password(default:$A$B$C): " ftp_passif [ -d ${directorys} ]; thenchmod -R 777 ${directorys}fiuseradd -d ${directorys} -g ftp -s /sbin/nologin ${ftp_user}if [ "${ftp_pass}" != "" ]; thenftp_passa="${ftp_pass}"elseftp_passa="$A$B$C"fiecho "${ftp_passa}" | passwd --stdin ${ftp_user} > /dev/nullecho "userdel ${ftp_user}" >> /etc/vsftpd/user_list.shif [ -d ${directorys} ]; thenchmod -R 777 ${directorys}fiecho "###################################"echo "FTP user:${ftp_user}"echo "Ftp password:${ftp_passa}"echo "The FTP directory:${directorys}"echo "-----------------------------------"}
uninstall_ftp()
{
yum -y remove vsftpd*
sh /etc/vsftpd/user_list.sh
echo "" > /etc/vsftpd/user_list.sh
}
case "${Stack}" ininstall)install_vsftp;;add)add_ftp;;uninstall)uninstall_ftp;;*)echo "Usage: $0 {install|add|uninstall}";;
esac

centos6一键安装vsftpd脚本下载:

wget http://www.tieww.com/soft/vsftp_root.sh && sh vsftp_root.sh

 

这篇关于centos6一键安装vsftpd脚本的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1150228

相关文章

Java使用ANTLR4对Lua脚本语法校验详解

《Java使用ANTLR4对Lua脚本语法校验详解》ANTLR是一个强大的解析器生成器,用于读取、处理、执行或翻译结构化文本或二进制文件,下面就跟随小编一起看看Java如何使用ANTLR4对Lua脚本... 目录什么是ANTLR?第一个例子ANTLR4 的工作流程Lua脚本语法校验准备一个Lua Gramm

如何在Mac上安装并配置JDK环境变量详细步骤

《如何在Mac上安装并配置JDK环境变量详细步骤》:本文主要介绍如何在Mac上安装并配置JDK环境变量详细步骤,包括下载JDK、安装JDK、配置环境变量、验证JDK配置以及可选地设置PowerSh... 目录步骤 1:下载JDK步骤 2:安装JDK步骤 3:配置环境变量1. 编辑~/.zshrc(对于zsh

如何在pycharm安装torch包

《如何在pycharm安装torch包》:本文主要介绍如何在pycharm安装torch包方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录在pycharm安装torch包适http://www.chinasem.cn配于我电脑的指令为适用的torch包为总结在p

在PyCharm中安装PyTorch、torchvision和OpenCV详解

《在PyCharm中安装PyTorch、torchvision和OpenCV详解》:本文主要介绍在PyCharm中安装PyTorch、torchvision和OpenCV方式,具有很好的参考价值,... 目录PyCharm安装PyTorch、torchvision和OpenCV安装python安装PyTor

Python Transformer 库安装配置及使用方法

《PythonTransformer库安装配置及使用方法》HuggingFaceTransformers是自然语言处理(NLP)领域最流行的开源库之一,支持基于Transformer架构的预训练模... 目录python 中的 Transformer 库及使用方法一、库的概述二、安装与配置三、基础使用:Pi

如何解决mmcv无法安装或安装之后报错问题

《如何解决mmcv无法安装或安装之后报错问题》:本文主要介绍如何解决mmcv无法安装或安装之后报错问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mmcv无法安装或安装之后报错问题1.当我们运行YOwww.chinasem.cnLO时遇到2.找到下图所示这里3.

Python 安装和配置flask, flask_cors的图文教程

《Python安装和配置flask,flask_cors的图文教程》:本文主要介绍Python安装和配置flask,flask_cors的图文教程,本文通过图文并茂的形式给大家介绍的非常详细,... 目录一.python安装:二,配置环境变量,三:检查Python安装和环境变量,四:安装flask和flas

使用Python实现一键隐藏屏幕并锁定输入

《使用Python实现一键隐藏屏幕并锁定输入》本文主要介绍了使用Python编写一个一键隐藏屏幕并锁定输入的黑科技程序,能够在指定热键触发后立即遮挡屏幕,并禁止一切键盘鼠标输入,这样就再也不用担心自己... 目录1. 概述2. 功能亮点3.代码实现4.使用方法5. 展示效果6. 代码优化与拓展7. 总结1.

Win11安装PostgreSQL数据库的两种方式详细步骤

《Win11安装PostgreSQL数据库的两种方式详细步骤》PostgreSQL是备受业界青睐的关系型数据库,尤其是在地理空间和移动领域,:本文主要介绍Win11安装PostgreSQL数据库的... 目录一、exe文件安装 (推荐)下载安装包1. 选择操作系统2. 跳转到EDB(PostgreSQL 的

微信公众号脚本-获取热搜自动新建草稿并发布文章

《微信公众号脚本-获取热搜自动新建草稿并发布文章》本来想写一个自动化发布微信公众号的小绿书的脚本,但是微信公众号官网没有小绿书的接口,那就写一个获取热搜微信普通文章的脚本吧,:本文主要介绍微信公众... 目录介绍思路前期准备环境要求获取接口token获取热搜获取热搜数据下载热搜图片给图片加上标题文字上传图片