centos6一键安装vsftpd脚本
生活随笔
收集整理的這篇文章主要介紹了
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以上無法安裝)
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脚本的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《秋江晚泊》是谁的作品?
- 下一篇: 2022-2028年中国除螨仪行业市场前