一键安装脚本 只需要自己设置一下脚本开头的几个字符串参数即可

#!/bin/bash
port=""
user="code"
pass=""
dir="/root/web"
ip="123.125.114.144"
yum -y install vsftpd*
yum -y install pam*
yum -y install db4* echo "install ok"
rm -rf /etc/vsftpd
mkdir /etc/vsftpd
rm -f /etc/vsftpd/vsftpd.conf
cat >/etc/vsftpd/vsftpd.conf<<EOF
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=
ascii_upload_enable=YES
ascii_download_enable=YES
listen=YES
listen_port=$port
pam_service_name=vsftpd
chroot_list_enable=YES
pasv_promiscuous=YES
pasv_enable=YES
pasv_min_port=
pasv_max_port=
pasv_address=$ip
use_localtime=YES
dual_log_enable=YES pam_service_name=vsftpd
guest_enable=YES
guest_username=ftp
user_config_dir=/etc/vsftpd/vuser_conf
EOF rm -f /etc/vsftpd/chroot_list
touch /etc/vsftpd/chroot_list
rm -f /etc/vsftpd/vuser_passwd.txt
cat >/etc/vsftpd/vuser_passwd.txt<<EOF
$user
$pass
EOF rm -f /etc/vsftpd/vuser_passwd.db
db_load -T -t hash -f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db rm -f /etc/pam.d/vsftpd
cat >/etc/pam.d/vsftpd<<EOF
auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_passwd
account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_passwd
EOF rm -rf /etc/vsftpd/vuser_conf/
mkdir /etc/vsftpd/vuser_conf/ rm -f /etc/vsftpd/vuser_conf/code
cat >/etc/vsftpd/vuser_conf/code<<EOF
local_root=$dir
allow_writeable_chroot=YES
chroot_local_user=YES
write_enable=YES
anon_umask=
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
EOF mkdir -p $dir
chmod -R $dir
chown -R $user:$user $dir
setenforce
service vsftpd stop
service vsftpd start
systemctl stop vsftpd
systemctl start vsftpd
/sbin/iptables -D INPUT -p tcp --dport $port -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport $port -j ACCEPT
/sbin/iptables -D INPUT -p tcp --dport : -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport : -j ACCEPT
netstat -tunlp|grep $port

如果出现如下错误

 OOPS: unrecognised variable in config file: allow_writeable_chroot

说明你安装的vsftpd版本稍微有点旧 不支持变量allow_writeable_chroot 编辑/etc/vsftpd/vuser_conf/code文件  在allow_writeable_chroot前面加一个#就可以注释了

然后重启一下vsfpds

service vsftpd restart
												

centos安装FTP脚本的更多相关文章

  1. centos 安装FTP server详情(转)

    centos 安装FTP server详情 分类: linux 2013-12-27 16:45 227人阅读 评论(0) 收藏 举报 我们这里以安装vsftpd 服务器端为例子: 1.进入到cent ...

  2. CentOS 安装ftp

    Linux安装ftp组件 1 安装vsftpd组件 安装完后,有/etc/vsftpd/vsftpd.conf 文件,是vsftp的配置文件. [root@bogon ~]# yum -y insta ...

  3. 基于CentOS安装FTP服务器

    操作系统环境: CentOS Linux release 7.4.1708 (Core) 使用yum安装ftp服务: yum install -y vsftpd 添加系统用户作为登录ftp服务器并修改 ...

  4. Centos 安装 FTP

    安装教程:   基于 CentOS 搭建 FTP 文件服务 搭建完成后,使用windows文件夹访问FTP报错,请确保输入的文件名是否正确,并且您有权访问此文件. 先确认ftp服务正常 修改:   设 ...

  5. centos 安装ftp服务器

    CentOS下搭建FTP服务器简单记录. 1.安装vsftpd yum install vsftpd 2.编辑iptablesvi /etc/sysconfig/iptables -A INPUT - ...

  6. CentOS安装FTP服务

    最近公司有一个内部比赛(黑客马拉松),报名参加了这么一个赛事,在准备参赛作品的同时(参赛服务器需要自己搭建),借着这个机会,决定把tomcat部署相关的知识从0到1重新捋一遍.就当备忘录了. FTP服 ...

  7. 阿里云centos安装ftp与svn过程

    1.下载xshell或者secureCRT 2.登录centos或者服务器 3.安装vsftpd [root@xxx]# yum install vsftpd //安装vsftpd [root@xxx ...

  8. Linux centos 安装 ftp(Vsftp) 与 设置ftp(Vsftp)

    本文章只是简单搭建,因为公司只须要简单使用,虽然简单但是之前也走了一些弯路,所以决定把过程记录下来. 一.Vsftp安装与卸载 安装:yum install vsftpd 卸载:yum remove ...

  9. centos安装ftp

    yum install -y vsftpd安装vsftpd service vsftpd start 启动vsftpd vim /etc/vsftpd/vsftpd.conf 将anonymous_e ...

随机推荐

  1. cube-ui indexList的正确使用

    demo地址:https://github.com/zphtown/cube-ui-bug 上拉和下拉核心代码: onPullingDown () { this.isNoMore = false th ...

  2. JVM--对象访问和OutOfMemoryError异常

        对象访问: 使用句柄访问方式: 使用直接指针访问方式: OutOfMemoryError异常: 设置堆的最小最大容量:-Xms20m -Xmx20m 设置一样推不可自动扩展. 设置出现内存溢出 ...

  3. 本地远程调试Linux 部署的web 项目

    1.在linux tomcat 下面的 bin 目录下增加一个远程调试的命令: declare -x CATALINA_OPTS="-server -Xdebug -Xnoagent -Dj ...

  4. Chrome中的插件运用

    1. Postman Java后台开发RPC,还没有没有开始和前端联调,只是想自测下这个RPC,但是有时候RPC的访问入参数据量很大,远远超过get方式访问2k(大多数浏览器通常都会限制url长度在2 ...

  5. vmware虚拟机安装centos7.3

    vmware准备 CentOS准备,这里下载的是CentOS 7.3CentOS-7-x86_64-Everything-1611.iso 创建新的虚拟机 选择自定义安装 硬件兼容性默认最新的,不用动 ...

  6. Linux: df du

    df :列出文件系统的整体磁盘使用量 du :评估文件系统的磁盘使用量(常用在推估目录所占容量) 1 df  :[-ahikHTm] 目录或文件名 选项或参数: -a:  列出所有的文件系统,包括系统 ...

  7. php+ajax远程加载避免重复提交

    近日在练习签到送积分功能时,发现可以在一瞬间的时候提交好多次 导致可以重复领取多次积分 除了增加请求限制之外 发现ajax提交没有限制重复提交 遂立此贴为警示 首先上表单代码 <form ons ...

  8. 会了docker你又多了一个谈资(上)

    相信有到现在为止还是有很多同学只是听说过docker,但还不了解docker.也很想学习,但是又不知道从何入手,工作中又接触不到,而自己又懒得去翻阅各种学习资料,那么,读完本文,我保证,docker的 ...

  9. 第三次java测验2

    package java3; public class Suiji { public long a=12345L;//定义long类型的a,b,c变量 public long c=12345L; pu ...

  10. svn提交报错 解决方法

    1.先clean 2.删除 .lock文件 3.update项目 4.先还原文件,然后update 接着commit