1、安装 vsftpd

​[root@CentOS ftp]# yum -y install vsftpd
2、启动 vsftpd 服务

​[root@CentOS ~]# systemctl start vsftpd.service # 启动 vsftpd 服务
[root@CentOS ~]# ps -ef | grep vsftpd # 查看 vsftpd 进程是否存在
root 3753 1 0 18:51 ? 00:00:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
root 3758 3494 0 18:51 pts/0 00:00:00 grep --color=auto vsftpd
[root@CentOS ~]#
3、开放 21 端口

​[root@CentOS ~]# firewall-cmd --zone=public --add-port=21/tcp --permanent # 添加 21 端口
success
[root@CentOS ~]# firewall-cmd --reload # 重新载入
success
[root@CentOS ~]# firewall-cmd --zone=public --list-ports # 查看所有已开放的端口
21/tcp 3690/tcp 3306/tcp # 可以看到 21 端口已开放
[root@CentOS ~]#
4、使用FileZilla进行客户端测试

(1)首先,将传输模式设置为主动模式:

(2)然后测试匿名登录:

​​使用匿名用户登录成功后,默认的主目录为 /var/ftp ,可以看到在该目录中有一个pub目录。

​[root@CentOS ~]# ls -l /var/ftp
总用量 0
drwxr-xr-x. 2 root root 6 8月 3 2017 pub # 确认pub目录已存在
[root@CentOS ~]#
5、配置 selinux

默认情况下,CentOS 的FTP 是不允许实体账号登录取得用户主目录数据的,这是因为 SELinux 的问题。

​[root@CentOS ~]# getsebool -a | grep ftp # 查看有关 ftp 的 selinux 策略规则
ftpd_anon_write --> off
ftpd_connect_all_unreserved --> off
ftpd_connect_db --> off
ftpd_full_access --> off
ftpd_use_cifs --> off
ftpd_use_fusefs --> off
ftpd_use_nfs --> off
ftpd_use_passive_mode --> off
httpd_can_connect_ftp --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_home_dir --> off
[root@CentOS ~]# setsebool -P tftp_home_dir=1 # 将 tftp_home_dir 规则设置为 1
6、建立 ftp 账户

新建一个不能登录系统,而只能登录 ftp 服务的用户。

​[root@CentOS ~]# useradd ftpuser -s /sbin/nologin # 添加用户 ftpuser
[root@CentOS ~]# passwd ftpuser # 设置密码
7、配置 vsftpd.conf

# 禁止匿名用户登录

anonymous_enable=NO

# 配置与实体用户相关的信息,可写入

userlist_enable=YES

userlist_deny=NO

userlist_file=/etc/vsftpd/user_list

之所以配置以上信息项,是因为我想只让某些人可以使用 FTP,而直接添加的用户默认不可使用 FTP 这个服务。如果我们想查看更多有关这个文件的配置说明,可以通过 man 5 vsftpd.conf 命令进行查看。

8、将 ftpuser 用户添加到 /etc/vsftpd/user_list 文件中,编辑后的内容如下:

​[root@CentOS ~]# cat /etc/vsftpd/user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
#root
#bin
#daemon
#adm
#lp
#sync
#shutdown
#halt
#mail
#news
#uucp
#operator
#games
#nobody
ftpuser # 指定只有 ftpuser 用户可以使用 FTP 服务,其他用户不能使用(已注释的用户)
[root@CentOS ~]#
此时写入 /etc/vsftpd/user_list 的用户就是可以使用 FTP 的账号了。所以未来添加的用户如果想使用 FTP 的话,也必须要写入这个文件。

9、重启 vsftpd 服务

​[root@CentOS ~]# systemctl restart vsftpd.service
[root@CentOS ~]# ps -ef | grep vsftpd
root 4568 1 0 19:51 ? 00:00:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
root 4573 3494 0 19:51 pts/0 00:00:00 grep --color=auto vsftpd
[root@CentOS ~]#
10、再次使用 FileZilla 进行测试

​​​

如上所示,用户 ftpuser 已登录成功,默认的用户主目录为 /home/ftpuser。

11、将 vsftpd 服务设置为开机启动

​[root@CentOS ~]# systemctl enable vsftpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@CentOS ~]#

Centos7搭建FTP服务的更多相关文章

  1. Centos7搭建FTP服务详细过程

    Centos7搭建FTP服务详细过程https://blog.csdn.net/sinat_30802291/article/details/81706152

  2. Centos7 搭建FTP服务

    安装vsftpd yum install -y vsftpd 修改配置文件 cd /etc/vsftpd user_list # 白名单 ftpusers # 黑名单 vsftpd.conf # 配置 ...

  3. centos7中搭建ftp服务

    博客搬家: centos7中搭建ftp服务 最近想和同学共享一些文件资源,于是在实验室服务器上搭建个ftp服务,本博客记录一下配置的流程.过程基本是参照别人的方法来做的,博客也是在别人博客基础上修改的 ...

  4. Linux(Centos7) 实例搭建 FTP 服务

    本文以 CentOS 7.2 64位系统为例,使用 vsftpd 作为 FTP 服务端,FileZilla 作为客户端.指导您如何在 Linux 云服务器上搭建 FTP 服务. 操作步骤 安装 vsf ...

  5. 在Win7的IIS上搭建FTP服务及用户授权

    FTP服务 FTP是文件传输协议(File Transfer Protocol)的简称,该协议属于应用层协议(端口号通常为21),用于Internet上的双向文件传输(即文件的上传和下载).在网络上有 ...

  6. 在Win7的IIS上搭建FTP服务及用户授权——转载!!

    原文地址:http://blog.sina.com.cn/s/blog_6cccb1630100q0qg.html FTP服务 FTP是文件传输协议(File Transfer Protocol)的简 ...

  7. 【阿里云】在 Windows Server 2016 下使用 FileZilla Server 安装搭建 FTP 服务

     Windows Server 2016 下使用 FileZilla Server 安装搭建 FTP 服务 一.安装 Filezilla Server 下载最新版本的 Filezilla Server ...

  8. 【转】在Win7的IIS上搭建FTP服务及用户授权

    [转]在Win7的IIS上搭建FTP服务及用户授权 [转]在Win7的IIS上搭建FTP服务及用户授权 FTP服务 FTP是文件传输协议(File Transfer Protocol)的简称,该协议属 ...

  9. FTP相关、用vsftpd搭建ftp、xshell使用xftp传输文件、使用pure-ftpd搭建ftp服务

    1.FTP相关(file transfer protocol,文件传输协议)   2.用vsftpd搭建ftp安装:yum install vsftpd -y创建一个虚拟用户:useradd  vft ...

随机推荐

  1. 计蒜客T2202 数三角形(提高组2017模拟赛(三)day2T3) LZOJ3878攻略

    今天模拟赛考了一道计蒜客NOIP2017模拟赛(三)day2T3的数三角形,原题链接 https://nanti.jisuanke.com/t/T2202 ,LZOJ3878攻略.场上想了很久都没转化 ...

  2. [shell]管道连接的命令判断返回值

    场景: 在bash执行管道连接的命令,需要获取到各个命令的返回值用于判断 在脚本中我们可能需要将执行结果打印到屏幕,同时保存在文件中供后面分析用,写出如下的命令 command 2>&1 ...

  3. 分布式-信息方式-ActiveMQ结合Spring

    ActiveMQ结合 Spring开发■ Spring提供了对JMS的支持,需要添加 Spring支持jms的包,如下: <dependency> <groupId>org.a ...

  4. Redis Cluster in Ubuntu

    1. 首先,进到Redis-server 的位置,确认 Redis server 可以正常启动 2. 在 redis-5.0.3 目录下创建文件夹 redisCluster_Demo_byMe,并在  ...

  5. java链接Mysql出现警告:Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by

    Java使用mysql-jdbc连接MySQL出现如下警告: Establishing SSL connection without server's identity verification is ...

  6. eclipse中设置tab为4个空格

    1.insert space for tabs前打勾 2.General settings中选择Spaces only 3.搞定

  7. uni-app tabBar 踩坑

    { "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { "pa ...

  8. kkfileview v2.0 发布,文件在线预览项目方案

    kkfileview文件在线预览 此项目为文件文档在线预览项目解决方案,项目使用流行的spring boot搭建,易上手和部署,部署好后可以独立提供预览服务,使用http接口访问,不需要和应用集成,具 ...

  9. DAY 2模拟赛

    DAY2 依旧是yyx出题 依旧毒瘤 滞空(jump/1s/64M) 题目描述: pyy在平面上第一象限内发现了顺序n个平台(她可以踩在这些平台上,但必须从第i-1号平台跳跃至i-1号平台),这些平台 ...

  10. XPath2Doc,一个半自动采集网页生成Word Docx文件的工具,带企查查和天眼查模板

    原始出处:https://www.cnblogs.com/Charltsing/p/XPath2Doc.html 很多人需要从网站采集一些数据填写Word模板,手工操作费时费力还容易出错,所以我给朋友 ...