安装vsftpd

命令:yum -y install vsftpd

修改ftp配置文件

命令:vim /etc/vsftpd/vsftpd.conf

按i进入insert模式后,按以下要求修改

anonymous_enable=YES

#改为anonymous_enable=NO

chroot_local_user=YES

#去掉前面的注释

#chroot_list_enable=YES

#chroot_list_file=/etc/vsftpd/chroot_list

#不受限制的用户列表,用不用都OK

allow_writeable_chroot=YES  

#加上这行解决了无法登陆的问题(重点,不然可能会出现530问题)

重启ftp

systemctl start vsftpd.service

systemctl restart vsftpd.service

设置开机启动ftp

systemctl enable vsftpd.service

配置防火墙(重点!)

#先检查是否安装了iptables
service iptables status
#安装iptables
yum install -y iptables
#升级iptables
yum update iptables 
#安装iptables-services
yum install iptables-services

禁用/停止自带的firewalld服务

#停止firewalld服务
systemctl stop firewalld
#禁用firewalld服务
systemctl mask firewalld

设置现有规则

#查看iptables现有规则
iptables -L -n
#先允许所有,不然有可能会杯具
iptables -P INPUT ACCEPT
#清空所有默认规则
iptables -F
#清空所有自定义规则
iptables -X
#所有计数器归0
iptables -Z
#允许来自于lo接口的数据包(本地访问)
iptables -A INPUT -i lo -j ACCEPT
#开放22端口
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#开放21端口(FTP)
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
#开放80端口(HTTP)
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#开放443端口(HTTPS)
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
#允许ping
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
#允许接受本机请求之后的返回数据 RELATED,是为FTP设置的
iptables -A INPUT -m state --state  RELATED,ESTABLISHED -j ACCEPT
#其他入站一律丢弃
iptables -P INPUT DROP
#所有出站一律绿灯
iptables -P OUTPUT ACCEPT
#所有转发一律丢弃
iptables -P FORWARD DROP

其他规则设定

#如果要添加内网ip信任(接受其所有TCP请求)
iptables -A INPUT -p tcp -s 45.96.174.68 -j ACCEPT
#过滤所有非以上规则的请求
iptables -P INPUT DROP
#要封停一个IP,使用下面这条命令:
iptables -I INPUT -s ***.***.***.*** -j DROP
#要解封一个IP,使用下面这条命令:
iptables -D INPUT -s ***.***.***.*** -j DROP

保存规则设定

#保存上述规则
service iptables save

开启iptables服务

#注册iptables服务
#相当于以前的chkconfig iptables on
systemctl enable iptables.service
#开启服务
systemctl start iptables.service
#查看状态
systemctl status iptables.service

重启防火墙

命令:systemctl restart iptables.service

建立ftp账户

useradd -d /home/ftp -s /sbin/nologin ftpadmin

修改密码

命令:passwd  ftpadmin

#注意 ftpadmin为刚刚设定的用户名,输入两次密码即可

设置用户权限

chmod 777 /home/ftp

重启ftp

systemctl restart vsftpd.service

ok,ftp服务器搭建完成

CentOS 7搭建FTP服务器的更多相关文章

  1. CentOS 下搭建FTP服务器

    vsftpd是Linux下比较著名的FTP服务器,搭建FTP服务器当然首选这个.本文介绍了在CentOS 6 4下安装vsftpd.配置虚拟用户登录FTP的过程.正 vsftpd是Linux下比较著名 ...

  2. Centos下搭建ftp服务器

    完全不用那么麻烦,直接可以用xshell中自带的传输文件功能,下载客户端xftp安装就行,不用配置,可以在windows系统向Linux系统的任何文件地方上传下载文件,简单方便,大大节约时间, vsf ...

  3. centos 6 搭建ftp服务器支持匿名读写

    转载请注明: 凌云物网智科嵌入式实验室: http://iot-yun.com/     郭文学<guowenxue@gmail.com> vsftpd在运行时一定要关闭SELinux,否 ...

  4. 在阿里云主机上基于CentOS用vsftpd搭建FTP服务器

    最近需要在一台阿里云的云服务器上搭建FTP服务器,在这篇博文中分享一下我们根据实际需求进行的一些配置. ftp软件用的是vsftpd. vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序 ...

  5. (转)Centos搭建FTP服务器

    场景:ftp服务器对于在Linux服务器上进行文件操作太方便,在安装软件时候,大的软件也可以先上传再进行安装! 1 搭建FTP服务器 1.1 检查vsftpd 查看是否已经安装vsftpd rpm - ...

  6. 服务器linux centos 7.4 搭建ftp服务器

    此操作是在腾讯云服务器linux centos 7.4 完成搭建ftp服务器 vsftpd 的: 安装 vsftpd $ yum install vsftpd -y 启动 $ service vsft ...

  7. CentOS 6.5下快速搭建ftp服务器[转]

    CentOS 6.5下快速搭建ftp服务器 1.用root 进入系统 2.使用命令 rpm -qa|grep vsftpd 查看系统是否安装了ftp,若安装了vsftp,使用这个命令会在屏幕上显示vs ...

  8. CentOS 6.5下快速搭建ftp服务器

    来源:Linux社区 作者:Linux CentOS 6.5下快速搭建ftp服务器 1.用root 进入系统 2.使用命令 rpm -qa|grep vsftpd 查看系统是否安装了ftp,若安装了v ...

  9. CenOS搭建FTP服务器

    CenOS搭建FTP服务器 -------------------------------------------------------------------------准备工作--------- ...

随机推荐

  1. 第十章 Secret & Configmap (中)

    10.3 在Pod中使用Secret 10.3.1 Volume方式 apiVersion: v1 kind: Pod metaata: name: mypod spec: containers: - ...

  2. Ceph添加/删除Mon(ceph.conf)

    操作环境 ceph 0.87.7 Openstack liberty ubuntu 14.04 当前ceph配置文件如下 [global]fsid = c010eb34-ccc6-458d-9a03- ...

  3. CentOS7.6安装Redis

    官网下载地址:https://redis.io/download 第一步:软件下载安装 进行安装目录:cd /opt/software (如果目录不存在,请先创建目录) 下载二进制包:wget htt ...

  4. css style study

    <img style="float:none;display:block;margin:0px auto" src="images/aa.jpg"> ...

  5. jaegeropentracing的Java-client完整分布式追踪链

    jaegeropentracing的Java-client完整分布式追踪链,在分布式系统中透传trace信息 之前文章记录了jaegeropentracing的Java-client追踪链在单系统中的 ...

  6. iOS开发基础控件--UISegmentedControl

    UISegmentedControl全局外观设置 分段控件是我们常用的控件之一,今天把具体用法总结了下: 1.初始化UISegmentedControl [plain] view plaincopy ...

  7. 复制新增树状数据_ParentID也需要更新

    CREATE TABLE TreeShip(  [ID] uniqueidentifier PRIMARY KEY NOT NULL,  [Name] [nvarchar](50) NULL,  [R ...

  8. kubernetes ServiceAccount

    api server 启动参数增加 –admission_control=…,ServiceAccount,…

  9. java算法 蓝桥杯 洗牌

    问题描述 小弱T在闲暇的时候会和室友打扑克,输的人就要负责洗牌.虽然小弱T不怎么会洗牌,但是他却总是输. 渐渐地小弱T发现了一个规律:只要自己洗牌,自己就一定会输.所以小弱T认为自己洗牌不够均匀,就独 ...

  10. Vertex and fragment programs

    [Vertex and fragment programs] When you use vertex and fragment programs (the so called "progra ...