CentOS一键ftp
# Version : 1.0
# Author : 果子
# Date : -- ::
# Description : 只需要三步即可完成安装
# chmod a+x install_vsftpd.sh
# ./install_vsftpd install_server 安装相关服务
# ./install_vsftpd add_user 配置用户信息
# ./install_vsftpd start 启动服务
# Usage : 在浏览器或计算机地址中输入:ftp://192.168.0.1 即可访问,192.168.0.1为主机地址。
# More : 后续将增加一些安全性控制和批量创建用户
#
#
#!/bin/bash
#set -x #调试用
allow=YES
deny=NO
Sname=vsftpd
VFconf="/etc/vsftpd/vsftpd.conf"
VFstart="/etc/init.d/vsftpd"
VUser="/etc/vsftpd/vuser"
VUCdirectory="/etc/vsftpd/vuconf"
VFpam="/etc/pam.d/vsftpdd"
VFDirectory="/var/www/html"
DB4=db4
DB4UTILS="db4-utils"
DB4DEVEL="db4-devel"
sys_tem="/lib64"
http=apache
#----------主配置文件--------------
main_config()
{
if [ -d $sys_tem ];then
echo "Your system is 64bit"
systems=$sys_tem
else
echo "Your system is 32bit"
systems=/lib
fi
# touch $VFpam
sed -i 's/anonymous_enable=YES/anonymous_enable=NO/g' $VFconf
sed -i 's/#chown_uploads=YES/chown_uploads=NO/g' $VFconf
sed -i 's/#xferlog_file/xferlog_file/g' $VFconf
sed -i 's/#async_abor_enable=YES/async_abor_enable=YES/g' $VFconf
sed -i 's/#ascii_upload_enable=YES/ascii_upload_enable=YES/g' $VFconf
sed -i 's/#ascii_download_enable=YES/ascii_download_enable=YES/g' $VFconf
sed -i 's/#chroot_local_user=YES/chroot_local_user=YES/g' $VFconf
sed -i 's/pam_service_name=vsftpd/pam_service_name=vsftpdd/g' $VFconf
{
echo "guest_enable=$allow"
echo "guest_username=$http"
echo "user_config_dir=$VUCdirectory"
echo "virtual_use_local_privs=$allow"
} >> $VFconf
touch $VFpam
{
echo "auth sufficient $systems/security/pam_userdb.so db=$VUser"
echo "account sufficient $systems/security/pam_userdb.so db=$VUser"
} > $VFpam
}
#------------用户配置-----------------------
user_config ()
{
Uname=$
userhome="local_root="
userworld="anon_world_readable_only="
userupload="anon_upload_enable="
usermkdir="anon_mkdir_write_enable="
userothen="anon_mkdir_write_enable="
userwrite="write_enable="
echo -e "\033[31;40m ===Now configure the config file=== \033[0m"
if [ -d $VUCdirectory ];then
echo "The directory $VUCdirectory exsits."
else
mkdir $VUCdirectory
fi
echo "Your want to configure user is :$Uname"
read -p "Please input user home directory(default $VFDirectory)" home_dir
if [ "x$home_dir" != "x" ]
then
VFDirectory=$home_dir
fi
echo "Your home directory is: $VFDirectory"
touch "$VUCdirectory/$Uname" && echo -e "\033[31;40mSuccess to configure file=== \033[0m"
{
echo "$userhome$VFDirectory"
echo "$userwrite$allow"
echo "$userworld$deny"
echo "$userupload$allow"
echo "$usermkdir$allow"
echo "$userothen$allow"
} > $VUCdirectory/$Uname
chown -R $http:$http $VFDirectory
chmod -R $VFDirectory
}
#----------------增加用户---------------------
add_user()
{
echo "start add user..."
while [ ]
do
isok=y
echo -n "Do you want to add user?"
read -p "[Y/N]:" ok
if [ "x$ok" = "x" ]
then
continue
elif [ "x$ok" = "xN" ]
then
echo "=============Finish add user============="
break
fi
isok=$ok
if [ "x$isok" != "xY" ]
then
echo "Error input! please input Y/N "
continue
else
read -p "Input username: " username
read -p "Input userpasswd: " userpasswd
echo "Your username is: $username"
echo "Your userpasswd is: $userpasswd"
{
echo "$username"
echo "$userpasswd"
} >> $VUser
user_config $username
fi
done
db_load -T -t hash -f $VUser $VUser.db
}
#-----------------安装服务---------------------
install_server()
{
rpm -q $Sname
if [ $? -eq ];then
echo "vsftpd service has installed. "
else
yum install -y $Sname
fi
yum -y install "db4*"
}
#------------------------------------------------
case $ in
install_server)
echo "start install $Sname:"
install_server
main_config
;;
add_user)
add_user
;;
restart)
$VFstart restart
;;
start)
$VFstart start
;;
stop)
$VFstart stop
;;
*)
echo "Usage: $0 install_server|add_user|restart|start|stop"
exit
esac
exit
保存为 OneClickFtp.sh
具体操作看开头的注释
CentOS一键ftp的更多相关文章
- centos一键优化脚本
centos一键优化脚本:细节:http://oldboy.blog.51cto.com/2561410/1336488网络状态优化:http://oldboy.blog.51cto.com/2561 ...
- centos 安装FTP server详情(转)
centos 安装FTP server详情 分类: linux 2013-12-27 16:45 227人阅读 评论(0) 收藏 举报 我们这里以安装vsftpd 服务器端为例子: 1.进入到cent ...
- Centos 安装 FTP
安装教程: 基于 CentOS 搭建 FTP 文件服务 搭建完成后,使用windows文件夹访问FTP报错,请确保输入的文件名是否正确,并且您有权访问此文件. 先确认ftp服务正常 修改: 设 ...
- centos启用ftp功能
1.安装vsftpd组件,安装完后,有/etc/vsftpd/vsftpd.conf 文件,用来配置,还有新建了一个ftp用户和ftp的组,指向home目录为/var/ftp,默认是nologin(不 ...
- CentOS 安装ftp
Linux安装ftp组件 1 安装vsftpd组件 安装完后,有/etc/vsftpd/vsftpd.conf 文件,是vsftp的配置文件. [root@bogon ~]# yum -y insta ...
- 阿里云centos配置ftp和svn全过程
1.下载xshell 2.登录centos 3.安装vsftpd [root@xxx]# yum install vsftpd //安装vsftpd [root@xxx]# chkconfig vsf ...
- centos架设FTP服务器
1.安装vsftp在这里,我们架设的是虚拟用户,所谓虚拟用户就是没有使用真实的帐户,只是通过某种手段达到映射帐户和设置权限的目的.yum -y install vsftpd在CentOS中,这样就可以 ...
- Centos开启FTP及用户配置
vsftpd作为FTP服务器,在Linux系统中是非常常用的.下面我们介绍如何在centos系统上安装vsftp. 什么是vsftpd vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序 ...
- centos 安装ftp服务器
CentOS下搭建FTP服务器简单记录. 1.安装vsftpd yum install vsftpd 2.编辑iptablesvi /etc/sysconfig/iptables -A INPUT - ...
随机推荐
- hibernate+mysql的连接池配置
1:连接池的必知概念 首先,我们还是老套的讲讲连接池的基本概念,概念理解清楚了,我们也知道后面是怎么回事了. 以前我们程序连接数据库的时候,每一次连接数据库都要一个连接,用完后再释放.如果频繁的 ...
- [Java] JSP笔记 - 自定义标签
自定义标签的创建步骤: 自定义标签的四大功能: 自定义标签的类结构: 在 1.0 中呢, 可以将 <body-content> 的值设置为 JSP, 2.0中则不允许在自定义标签体中出现j ...
- Redis安装测试(待完善)
1 Redis安装 在网址http://redis.io/下载redis-3.2.3.tar.gz,解压. 进入解压目录 编译和安装,具体配置项可参考自带的README.md文件 make test ...
- 现代软件工程作业 第二章 Github的使用
Github的使用 创建团队 Github首页点击Create Orginazation,出现如下界面: 填写相关信息,邀请团队成员: 点击确认,创建团队完成,界面如下: 创建新的版本库 点击Crea ...
- 2013 Asia Regional Changchun C
Little Tiger vs. Deep Monkey Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K ( ...
- 安装 sublime2 (包括插件)
1.下载地址:http://www.sublimetext.com/2,注意选择不同的平台: 2.安装后,打开sublime,在菜单栏 help -- enter license 打开一个窗口,复制 ...
- PHP代码获取客户端IP地址经纬度及所在城市
echo $_SERVER['HTTP_HOST'];//echo $_SERVER['REQUEST_URI'];$getIp=$_SERVER["REMOTE_ADDR"];e ...
- ngSanitize和$sce
(angular-ngSanitize模块-$sanitize服务详解) 本篇主要讲解angular中的$sanitize这个服务.此服务依赖于ngSanitize模块. 要学习这个服务,先要了解另一 ...
- PYTHON lambda表达式
lambda相当于def定义函数 一一对应
- android3D动画,绕y轴旋转
原文地址:http://blog.csdn.net/x_i_a_o_h_a_i/article/details/40449847 其实网上的3D旋转的例子很多,在这里我只是想把其代码做一个解释. 先上 ...