Centos7搭建FTP服务
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服务的更多相关文章
- Centos7搭建FTP服务详细过程
Centos7搭建FTP服务详细过程https://blog.csdn.net/sinat_30802291/article/details/81706152
- Centos7 搭建FTP服务
安装vsftpd yum install -y vsftpd 修改配置文件 cd /etc/vsftpd user_list # 白名单 ftpusers # 黑名单 vsftpd.conf # 配置 ...
- centos7中搭建ftp服务
博客搬家: centos7中搭建ftp服务 最近想和同学共享一些文件资源,于是在实验室服务器上搭建个ftp服务,本博客记录一下配置的流程.过程基本是参照别人的方法来做的,博客也是在别人博客基础上修改的 ...
- Linux(Centos7) 实例搭建 FTP 服务
本文以 CentOS 7.2 64位系统为例,使用 vsftpd 作为 FTP 服务端,FileZilla 作为客户端.指导您如何在 Linux 云服务器上搭建 FTP 服务. 操作步骤 安装 vsf ...
- 在Win7的IIS上搭建FTP服务及用户授权
FTP服务 FTP是文件传输协议(File Transfer Protocol)的简称,该协议属于应用层协议(端口号通常为21),用于Internet上的双向文件传输(即文件的上传和下载).在网络上有 ...
- 在Win7的IIS上搭建FTP服务及用户授权——转载!!
原文地址:http://blog.sina.com.cn/s/blog_6cccb1630100q0qg.html FTP服务 FTP是文件传输协议(File Transfer Protocol)的简 ...
- 【阿里云】在 Windows Server 2016 下使用 FileZilla Server 安装搭建 FTP 服务
Windows Server 2016 下使用 FileZilla Server 安装搭建 FTP 服务 一.安装 Filezilla Server 下载最新版本的 Filezilla Server ...
- 【转】在Win7的IIS上搭建FTP服务及用户授权
[转]在Win7的IIS上搭建FTP服务及用户授权 [转]在Win7的IIS上搭建FTP服务及用户授权 FTP服务 FTP是文件传输协议(File Transfer Protocol)的简称,该协议属 ...
- FTP相关、用vsftpd搭建ftp、xshell使用xftp传输文件、使用pure-ftpd搭建ftp服务
1.FTP相关(file transfer protocol,文件传输协议) 2.用vsftpd搭建ftp安装:yum install vsftpd -y创建一个虚拟用户:useradd vft ...
随机推荐
- ABP .net Core MQTT+signalr通讯
abp版本: 4.3.0.0 .net core 版本 2.2 1.Mqtt 1.1 添加程序集:M2MqttDotnetCore(差点以为没有.net core 的) 2.2 实现代码:抄了个单例模 ...
- unittest详解(四) 批量执行用例(discover)
前面我们说了,对于不同文件用例,我们可以通过addTest()把用例加载到一个测试套件(TestSuite)来统一执行,对于少量的文件这样做没问题,但是如果有几十上百个用例文件,这样做就太浪费时间了. ...
- JavaWeb_(MVC)管理员后台商品查询demo
MVC分层实现管理员后台商品查询 MVC层即model view controller Model(模型):模型代表着核心的业务逻辑和数据(不要理解成Model只是实体类) View(视图):视图应该 ...
- JS框架_(JQuery.js)Tooltip弹出式按钮插件
百度云盘 传送门 密码:7eh5 弹出式按钮效果 <!DOCTYPE html> <html > <head> <meta charset="UTF ...
- RESTful API Design
https://restful-api-design.readthedocs.org/en/latest/scope.html http://blog.mashape.com/30-ways-to-m ...
- Java并发编程的艺术笔记(六)——HashMap、ConcurentHashMap的原理与实现
一.线程不安全的HashMap 多线程环境下,使用HashMap进行put操作会引起死循环(jdk1.7 Entry链表形成环形数据结构),导致CPU利用率接近100%. 结构:数组 table[]+ ...
- 套接字之msghdr结构
用户端在使用sendmsg/recvmsg发送或者接收数据时,会使用msghdr来构造消息,其对应的内核结构为user_msghdr:其中msg_iov向量指向了多个数据区,msg_iovlen标识了 ...
- 数据库 mysql 操作
安装好xammp,打开阿帕奇和数据库服务: 点击右侧 shell 按钮,进入命令行: 首先,利用超级管理员权限进入数据库: mysql -uroot -p enter,再enter 把下述代码复制进命 ...
- 作业要求20191010-3 alpha week 1/2 Scrum立会报告+燃尽图 01
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2019fall/homework/8746 一.小组情况组长:贺敬文组员:彭思雨 王志文 位军营 杨萍队名:胜 ...
- ForkJoin使用
一.Fork Join 分而治之的办法 JDk为Fork/Join框架提供了很好的支持,我们想要用这个算法首先得创建一个Fork/Join任务,在JDK中这个任务就叫做:ForJoinTask,只要继 ...