一、修改默认的防火墙firewaliptables

我在搭建ftp服务器的过程中,总是不成功,然后把防火墙换了以后,就莫名其妙的可以了,所以这里需要把防火墙换一下。
1、关闭原来的防火墙

systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动

2、安装iptables

yum -y install iptables-services

3、将iptables设置为开机启动

systemctl enable iptables.service #设置防火墙开机启动

4、我们既然要使用iptables,我们就需要配置防火墙可以通行的端口,一下是放行端口的方法:
首先打开配置文件:vim /etc/sysconfig/iptables

然后添加通行端口,例如:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

最后重新启动防火墙,使配置生效

systemctl restart iptables.service #重启防火墙使配置生效

二、安装vsftpd和修改相关的配置文件

1、通过yum安装vsftpd

yum install -y vsftpd

2、修改vsftpd的配置文件

vim /etc/vsftpd/vsftpd.conf

关于如何配置,这里只是关于我的配置,应该按照自己的要求自行修改:

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YESpam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
pasv_min_port=61001
pasv_max_port=62000
allow_writeable_chroot=YES

想要详细了解配置的可以参考:史上最详细的vsftpd配置文件讲解
3、在根目录下创建一个访问ftp服务器时访问的文件夹(这里在那创建都可以)

mkdir /ftpfile

4、添加匿名用户(不要忘了用passwd设置密码)

useradd ftpuser -d /ftpfile(自己的文件夹) -s /sbin/nologin

5、修改ftpfile文件夹权限

chown -R ftpuser.ftpuser /ftpfile

6、将我们的用户添加到chroot_list

vim /etc/vsftpd/chroot_list

添加创建的用户ftpuser,然后保存退出
7、将SELinux关闭

vim /etc/selinux/config

修改SELINUX=disabled

三、让防火墙通行ftp相关的端口

在防火墙配置文件中添加:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8009 -j ACCEPT
-A INPUT -p TCP --dport 61001:62000 -j ACCEPT
-A OUTPUT -p TCP --sport 61001:62000 -j ACCEPT

4、访问

这里的文件夹就是我们的ftpfile,我在其中添加了一些文件,还有就是我用的域名访问,如果没有域名,可以用ip访问

阿里轻量应用服务器搭建ftp服务器相关推荐

  1. 使用腾讯云轻量应用服务器搭建gitlab服务器

    使用腾讯云轻量应用服务器搭建gitlab服务器 前言:代码平台托管安全吗? 之前就有某科集团,在网络上面透露,托管在某云公共代码托管平台的源码发生泄漏,造成至少40多家企业200多个项目代码泄漏.所以 ...

  2. 腾讯云轻量应用服务器搭建LAMP 开发环境

    LAMP(Linux+Apache+MySQL+PHP)是目前国际流行的 Web 应用框架,包括了 Linux 操作系统.Apache Web 服务器.MySQL/MariaDB 数据库和 PHP 编 ...

  3. 腾讯云轻量应用服务器搭建网站

    目录 前言 1.初次登入腾讯云官网的先注册+学生认证 2.购买服务器 3.配置+导入前端文件 参考资料 前言 建站小白初次搭建网站流程分享,或许有诸多槽点.废话多多.术语乱用. 毫无逻辑,请谨慎食用. ...

  4. 腾讯云轻量应用服务器和云服务器的区别是什么?

    最近几次腾讯云秒杀中都推出了好几款性价比非常不错的腾讯云轻量应用服务器,相比于常规的腾讯云云服务器,同等价格的轻量应用服务器有更大的带宽,那么两者的区别是什么呢?有没有性能或者CPU上的限制?本文就分 ...

  5. 选轻量应用服务器or云服务器ECS?一图帮你彻底区分

    简介:轻量应用服务器适合轻量级且访问量低的应用场景,更适合个人开发者.对新手小白更友好:而云服务器ECS可覆盖全业务场景(如大数据分析,深度学习等),要求用户有一定的开发技术能力. 本文首发于公众号& ...

  6. 腾讯云轻量应用服务器搭建即时通信 IM系统

    我们如果想要搭建一个自己的即时通信系统,实现与好友的单聊或者创建群聊,这里推荐大家使用腾讯云的即时通信IM产品,部署十分简单,并且提供了免费版套餐可供试用.下面为大家介绍如何使用腾讯云轻量应用服务器搭 ...

  7. 腾讯云轻量应用服务器搭建跨境电商的方法步骤(非常详细)

     独立站火热的背后 对于中国的跨境电商平台卖家而言,2021年绝对是段低气压的时光:亚马逊掀起了一场规模庞大的"封号潮",自4月起至9月,从头部到中小品牌,粗略统计有超过5万家店铺 ...

  8. 腾讯云轻量应用服务器搭建wordpress之发送注册验证邮件

    最近在使用腾讯云轻量应用服务器搭建一个wordpress博客,用户使用注册功能时,需要给用户的邮箱发注册验证邮件. 2021.02.08更新:最后找了很久,用了一个插件能发出去邮件!还能替换原始的登录 ...

  9. 腾讯云轻量应用服务器和云服务器的区别是什么?哪个更好?

    腾讯云于2020年7月13日正式开始轻量应用服务器的公测,吸引了众多个人开发者甚至是中小企业前来体验及使用,用户反响非常热烈.相较于其明星产品云服务器来说,大家对轻量应用服务器非常陌生,甚至对它的用处 ...

  10. ​​2023年腾讯云轻量应用服务器和云服务器CVM区别

    抛开价格及使用门槛,云服务器CVM更好:从性价比及易用性角度考虑,轻量应用服务器更好.轻量服务器性价比高,这个配置这个价格是云服务器CVM所不及的.腾讯云百科来详细说下腾讯云轻量应用服务器和云服务器C ...

最新文章

  1. C++用数组和链表分别实现Stack
  2. 2020年6月学术会议变动汇总
  3. ROS 命令以及相关内容学习(二)
  4. POJ - 3347 Kadj Squares(思维+几何)
  5. 03.elasticsearch_index操作
  6. python3(六)监督学习
  7. java上传rar文件_java实现上传zip/rar压缩文件,自动解压
  8. linux服务器配置试卷,2016年Linux认证模拟练习题及答案
  9. null或空值的判断处理-java
  10. 数据库原理(一)—— 关系代数(二)
  11. 打印系统开发(6)——纸张尺寸对照表如下
  12. 百度地图迁徙大数据_百度地图发布春运大数据,2020年返程规模下降六成
  13. android 应用市场 审核速度,安卓市场上传APP软件要多长时间审核?
  14. 蓝桥杯day7——DFSBFS
  15. 【数据库系统综合实验】教学管理信息系统—学生选课及课程安排数据库综合实验
  16. 卷积神经网络学习项目--Kaggle仙人掌识别--基于TensorFlow(未完成)
  17. 【Android】期末简答题
  18. 不恰当使用线程池处理 MQ 消息引起的故障
  19. 抖音发广告需要注意什么,三个注意事项与规范要牢记
  20. 丁小帅+2016012047+作业5

热门文章

  1. “五一”或成疫情来最火爆假期,招行信用卡天天返利助力消费
  2. SAS编程|ADAM阶段性小结
  3. 【MATLAB笔记】对矩阵进行满秩分解
  4. 从零开始搭建Java环境
  5. 如何获取手机的屏幕尺寸
  6. 虚拟机配置opc服务器,组态王怎么配置成opc服务器
  7. 网红茶饮难逃“短命”之殇,喜茶能否打破这个魔咒?
  8. 罗格斯大学电子与计算机工程,罗格斯大学电子和计算机工程理学硕士研究生申请要求及申请材料要求清单...
  9. (转)一些jbx的配置
  10. SOAP Action介绍