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 ...
随机推荐
- sh_05_列表遍历
sh_05_列表遍历 name_list = ["张三", "李四", "王五", "王小二"] # 使用迭代遍历列表 ...
- Python3学习笔记(十四):可迭代对象、迭代器和生成器
记得在刚开始学Python的时候,看到可迭代对象(iterable).迭代器(iterator)和生成器(generator)这三个名词时,完全懵逼了,根本就不知道是啥意识.现在以自己的理解来详解下这 ...
- 导数与微分简单总结(updated)
只讲一些导数在OI中的简单应用,特别基础的东西,不会很详细也不会很全面. 导数的定义 设函数\(y=f(x)\)在点\(x_0\)的某个邻域内有定义,当自变量\(x\)在\(x_0\)处有增量\(Δx ...
- A. Be Positive
A. Be Positive time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 用JavaScript实现div的鼠标拖拽效果
实现原理鼠标按下时根据onmousemove事件来动态获取鼠标坐标位置以此来更新div的位置,实现的前提时div要有一个定位效果,不然的话是移动不了它的. HTML <div class=&qu ...
- java实现数据库之间批量插入数据
package comnf147Package; import java.sql.*; public class DateMigrationLagou { //连接SQLite private Con ...
- Shell实现交互式登陆一台同时管理多台机器
最近为了检测公司服务器的硬盘需要开10多台服务器的僚机来检测服务器,可是这10来台都是操作一样的命令,挨个操作下去太麻烦了 然后就想到了交互式登陆 这里需要创建一个Ip文件夹把你的Ip账户密码都放进去 ...
- Grunt打包Electron,生成exe的安装包
在之前的博客:3.electron打包生成exe文件 我们已经得到了electron打包好的应用了,目录如下,但是我们如何整合成一个安装程序,发给客户使用呢? 我们可以使用grunt-electron ...
- 本地git 添加多个远程仓库
1.在本地找到,~/.ssh 文件夹 2.执行 ssh-keygen -t rsa -C "Winseek" -f "id-rsa-github" 3.生成了i ...
- 浏览器端-W3School-HTML:HTML DOM Object 对象
ylbtech-浏览器端-W3School-HTML:HTML DOM Object 对象 1.返回顶部 1. HTML DOM Object 对象 Object 对象 Object 对象代表 HTM ...