centos6上快速安装vsftpd工具

简介

经常玩linux的对vsftpd这个工具不会陌生,vsftpd是一个类Unix系统以及Linux上的FTP服务器软件,安全性是最

大的特点,并且小巧轻快,完全免费开源。浪费人力的配置我这里就不介绍了,有机会再写,这里直接上一键脚本。

 

- 3330000606

 

教程

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

脚本代码如下,可以复制下面的脚本保存为vsftpd.sh然后开始运行

#!/bin/bash
Stack=$1
if [ "${Stack}" = "" ]; then
 Stack="install"
else
 Stack=$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 vsftpd
 if [ "$?" -eq "0" ]; then
 echo "You have to install VSFTPD!"
 else
 netstat -ntulp |grep -w 21
 if [ "$?" -eq "0" ]; then
 echo "Other FTP is already installed"
 else
 read -p "The FTP access directory(default:/home): " directory
 if [ "${directory}" != "" ]; then
 directorys="${directory}"
 else
 directorys="/home"
 fi
 read -p "Please enter the FTP user: " ftp_user
 read -p "Enter the FTP password(default:$A$B$C): " ftp_pass
 if [ "${ftp_pass}" != "" ]; then
 ftp_passa="${ftp_pass}"
 else
 ftp_passa="$A$B$C"
 fi
 yum -y install vsftpd
 if [ "$?" -eq "0" ]; then
 if [ -d ${directorys} ]; then
 chmod -R 777 ${directorys}
 fi
 useradd -d ${directorys} -g ftp -s /sbin/nologin ${ftp_user}
 echo "${ftp_passa}" | passwd --stdin ${ftp_user} > /dev/null
 sed -i 's/^anonymous_enable=YES/anonymous_enable=NO/g' /etc/vsftpd/vsftpd.conf
 sed -i 's/^#chroot_local_user=YES/chroot_local_user=YES/g' /etc/vsftpd/vsftpd.conf
 sed -i 's/^#chroot_list_enable=YES/chroot_list_enable=YES/g' /etc/vsftpd/vsftpd.conf
 echo "userdel ${ftp_user}" >> /etc/vsftpd/user_list.sh
 echo "" > /etc/vsftpd/chroot_list
 chkconfig vsftpd on
 service vsftpd restart
 echo "###################################"
 echo "FTP user:${ftp_user}"
 echo "Ftp password:${ftp_passa}"
 echo "The FTP directory:${directorys}"
 echo "-----------------------------------"
 else
 echo "VSFTPD installation failed!"
 fi
 fi
 fi
}
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): " directory
 if [ "${directory}" != "" ]; then
 directorys="${directory}"
 else
 directorys="/home"
 fi
 read -p "Please enter the FTP user: " ftp_user
 read -p "Enter the FTP password(default:$A$B$C): " ftp_pass
 if [ -d ${directorys} ]; then
 chmod -R 777 ${directorys}
 fi
 useradd -d ${directorys} -g ftp -s /sbin/nologin ${ftp_user}
 if [ "${ftp_pass}" != "" ]; then
 ftp_passa="${ftp_pass}"
 else
 ftp_passa="$A$B$C"
 fi
 echo "${ftp_passa}" | passwd --stdin ${ftp_user} > /dev/null
 echo "userdel ${ftp_user}" >> /etc/vsftpd/user_list.sh
 if [ -d ${directorys} ]; then
 chmod -R 777 ${directorys}
 fi
 echo "###################################"
 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}" in
 install)
 install_vsftp
 ;;
 add)
 add_ftp
 ;;
 uninstall)
 uninstall_ftp
 ;;
 *)
 echo "Usage: $0 {install|add|uninstall}"
 ;;
esac

也可以刷下面的一键配置脚本

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

vsftpd脚本功能:

1.安装 (命令执行:sh vsftpd.sh)

2.添加ftp用户 (命令执行:sh vsftpd.sh add)

3.卸载vsftpd (命令执行:sh vsftpd.sh uninstall)
上一篇 一招检查MariaDB服务端版本号
下一篇 Truobox:1核/4GB/15TB流量/320GB硬盘/KVM/美国OVH/200M带宽/$7.7/月

投稿邮箱:
ivpsr888@gmail.com (投稿详情)

TG订阅频道:
t.me/ivpsr_news 网站最新内容推送

TG交流群:
(点击加入) 用户交流

文章列表
1
Evoxt:新年促销充值活动,充就送,活动时间有限,美国/英国/马来西亚VPS低至2.99美元/月
Evoxt:新年促销充值活动,充就送,活动时间有限,美国/英国/马来西亚VPS低至2.99美元/月
2
VPS IP纯净度检测指南,远离脏IP、跳盾与账号风控
VPS IP纯净度检测指南,远离脏IP、跳盾与账号风控
3
Git命令行代码合集,整理列出你常用的命令的
Git命令行代码合集,整理列出你常用的命令的
4
伏羲云日本软银G口/日本CN2/日本CN2大带宽/美国Cera CN2 GIA月付85折优惠码 2020.10.10
伏羲云日本软银G口/日本CN2/日本CN2大带宽/美国Cera CN2 GIA月付85折优惠码 2020.10.10
5
win10上vs code配置git让你的Visual Studio Code轻松提交到仓库
win10上vs code配置git让你的Visual Studio Code轻松提交到仓库
6
FormoHost马来西亚VPS测评|原生IP验证与国内速度实测(2026)
FormoHost马来西亚VPS测评|原生IP验证与国内速度实测(2026)
7
DediPath宣布停止运营,抓紧时间迁移服务器数据进行备份
DediPath宣布停止运营,抓紧时间迁移服务器数据进行备份
8
欧路云:两周年活动6折循环优惠码,CN2 GIA/AS9929 低至 2.4美元/月
欧路云:两周年活动6折循环优惠码,CN2 GIA/AS9929 低至 2.4美元/月
9
DiyVM CN2不限流量VPS,美国/香港机房月付50元起
DiyVM CN2不限流量VPS,美国/香港机房月付50元起
10
BinaryRacks:英国独立服务器,5折大促,月付低至$29起,伦敦 机房 E5-2650/64GB 内存/100TB 流量/1Gbps带宽
BinaryRacks:英国独立服务器,5折大促,月付低至$29起,伦敦 机房 E5-2650/64GB 内存/100TB 流量/1Gbps带宽