1.在linux系统中安装vsftpd服务
yum install -y vsftpd
2.新建两个测试用户
useradd ftpuser1 && echo "123456"|passwd --stdin ftpuser1
useradd ftpuser2 && echo "123456"|passwd --stdin ftpuser2
3.修改配置文件
anonymous_enable=NO #关闭匿名访问
user_config_dir=/etc/vsftpd/vsftpd_user_conf #添加至文件末尾,指定配置文件
4.将允许登陆用户名插入到vsftpd.chroot_list
echo 'ftpuser1' >>/etc/vsftpd/chroot_list
echo 'ftpuser2' >>/etc/vsftpd/chroot_list
5.创建配置文件目录
mkdir /etc/vsftpd/vsftpd_user_conf
6.创建ftp1用户对应的配置文件
vim /etc/vsftpd/vsftpd_user_conf/ftpuser1
#只能上传。不能下载、删除、重命名。
cmds_allowed=FEAT,REST,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RMD,SIZE,STOR,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST
#配置登陆后默认所在目录
local_root=/home/ftpuser1
7.创建ftp2用户对应的配置文件
vim /etc/vsftpd/vsftpd_user_conf/ftpuser1
#只能下载、删除、重命名。不能上传。
cmds_allowed=FEAT,REST,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RMD,RNFR,RNTO,RETR,DELE,SIZE,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST
8.启动vsftpd,并配置开机自启
systemctl start vsftpd
systemctl enable vsftp
配置文件详解
# ABOR - abort a file transfer 取消文件传输
# CWD - change working directory 更改目录
# DELE - delete a remote file 删除文件
# LIST - list remote files 列目录
# MDTM - return the modification time of a file 返回文件的更新时间
# MKD - make a remote directory 新建文件夹
# NLST - name list of remote directory
# PASS - send password
# PASV - enter passive mode
# PORT - open a data port 打开一个传输端口
# PWD - print working directory 显示当前工作目录
# QUIT - terminate the connection 退出
# RETR - retrieve a remote file 下载文件
# RMD - remove a remote directory
# RNFR - rename from
# RNTO - rename to
# SITE - site-specific commands
# SIZE - return the size of a file 返回文件大小
# STOR - store a file on the remote host 上传文件
# TYPE - set transfer type
# USER - send username
# less common commands:
# ACCT* - send account information
# APPE - append to a remote file
# CDUP - CWD to the parent of the current directory
# HELP - return help on using the server
# MODE - set transfer mode
# NOOP - do nothing
# REIN* - reinitialize the connection
# STAT - return server status
# STOU - store a file uniquely
# STRU - set file transfer structure
# SYST - return system type
几个例子:
# 1、只能上传。不能下载、删除、重命名。
cmds_allowed=FEAT,REST,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RMD,SIZE,STOR,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST
# 2、只能下载。不能上传、删除、重命名。
write_enable=NO
# 3、只能上传、删除、重命名。不能下载。
download_enable=NO
#4、只能下载、删除、重命名。不能上传。
cmds_allowed=FEAT,REST,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RMD,RNFR,RNTO,RETR,DELE,SIZE,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST