- 操作系统 CentOS7.4
-
安装 yum install vsftpd -y
-
配置vsftpd.conf
egrep -v “#|$” ** /etc/vsftpd/vsftpd.conf **
anonymous_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
write_enable=YES
local_umask=000
local_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list #在此文件中的用户可以cd 到自己的家目录外
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
allow_writeable_chroot=YES
user_config_dir=/etc/vsftpd/userconfig #为每个用户分配特定的权限的目录 下面放置和用户名相同的文件来限制每个用户的权限 -
创建本地账号test,并设置密码
useradd -d /data/ftp/test -m -s /sbin/nologin test
echo “test” | passwd --stdin test
此时登录 使用test 账号登录 默认根目录是 /data/ftp/test,并被锁定到根目录下,如果需要切换到根目录外可以把此用户名 写入chroot_list_file=/etc/vsftpd/chroot_list 这个文件中。
/etc/vsftpd/user_list 按照第二部配置的此时为 黑名单
/etc/vsftpd/ftpusers 黑名单(/etc/pam.d/vsftpd中配置) -
单独与test 账号设置权限
mkdir -p /etc/vsftpd/userconfig
cd /etc/vsftpd/userconfig
touch test
更改test 用户的登录的根目录:
local_root=/data/test
设置test 用户只能上传,禁止改名,删除,新建等 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
- 以下是常用的一些参数,仅供参考!
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