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 ...
随机推荐
- HGOI20190815 题解
Problem A modsum 求$\sum\limits_{i=1}^{n} \sum\limits_{j=1 , i \neq j}^{m} (n \ mod \ i)(m \ mod \ j) ...
- HGOI20190811 省常中互测4
Problem A magic 给出一个字符串$S$,和数字$n$,要求构造长度为$n$只含有小写字母的字符串$T$, 使得在$T$中存在删除且仅删除一个子串使得$S=T$成立. 输出$T$的构造方案 ...
- 分区间统计sql、删除重复数据
删除重复数据 备份表 删除最早的评论
- latex参考文献中作者名字含有特殊字符怎么办
- vue router 报错:NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}
https://blog.csdn.net/weixin_43202608/article/details/98884620
- linux下安装R
下载 版本:R3.2.2 下载地址:http://cran.rstudio.com/src/base/R-3/R-3.2.2.tar.gz 安装步骤: 解压 tar -zxvf R-3.2.2.tar ...
- 半径R覆盖最多点
struct point { double x, y; }; point p[N]; struct alpha { double v; bool flag; bool friend operator ...
- jdbcTemplate的queryForList的使用方法
jdbcTemplate的queryForList的使用方法如下,它不一样的地方是,它获得的结果,会再放到一个map里去: List rows = jdbcTemplate.queryForList( ...
- leetcode 496下一个更大的元素I
单调递减栈来做,time O(n),spaceO(n)需要一个哈希map class Solution { public: vector<int> nextGreaterElement(v ...
- python问题笔记
1.for...in...:和while...:循环末端都可以有一个else:语句,但他仅在循环不是由break语句退出时才会被运行 2.input raw input区别 一. 可以看到:这两个函数 ...