前提条件
- CentOS7,root用户操作
如果是CentOS6,有一些操作命令会不同,如启动防火墙…
CentOS6用的防火墙是iptables,CentOS7用的是filewall
安装步骤
- 下载安装vsftpd
yum -y install vsftpd
- 在根目录创建ftpfile文件夹
cd /
mkdir -p /ftpfile/ftpfile
- 给ftp服务器创建一个用户,用户只对ftpfile文件夹有权限,并且没有登录权限(忽略警告)
# useradd ftpuser:创建用户ftpuser
# -s /sbin/nologin:让ftpuser用户不能登录linux
useradd ftpuser -s /sbin/nologin
# 让ftpuser用户拥有/ftpfile/ftpfile/文件夹和其子文件夹的权限
chown -R ftpuser.ftpuser /ftpfile/ftpfile/
- 查看一下ftpfile文件夹的权限
cd /ftpfile
ll | grep ftp
- 重置一下ftpuser的密码
passwd ftpuser
- 在/ftpfile/ftpfile文件夹中创建一个文件
touch index.html
- 配置ftp服务器(把配置只想刚刚创建的目录,并且配置上用户)
vim /etc/vsftpd/vsftpd.conf
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.
#