给每个虚拟用户单独建立目录,并建立自己的配置文件,方便单独配置权限,并可以单独制定上传目录。
1 [root@imxhy ~]# mkdir /etc/vsftpd/vusers_dir #创建配置文件保存目录
注意:1 此为目录,非文件,单独保存了虚拟用户的配置文件
1 [root@imxhy ~]# vi /etc/vsftpd/vsftpd.conf
2 local_root=/home/vftproot/ #用于其他用户继承的主目录
3 user_config_dir=/etc/vsftpd/vusers_dir #指定保存虚拟用户配置文件的目录
注意:1 如没有给虚拟用户单独指定配置文件,则默认继承主配置文件vsftpd.conf的配置
1 [root@imxhy vusers_dir]# cd /etc/vsftpd/vusers_dir/
2 [root@imxhy vusers_dir]# vi ftptest01 #单独的配置文件名必须和虚拟用户名一致
3 anon_upload_enable=YES
4 anon_mkdir_write_enable=YES
5 anon_other_write_enable=YES #允许此用户上传
6 local_root=/home/ftptest01 #指定独立的上传目录
1 [root@imxhy ~]# mkdir /home/ftptest01 #创建独立的目录
2 [root@imxhy ~]# chown vuser /home/ftptest01/
3 #能否上传需要FTP服务权限,同时也需要上传目录的权限,因此需要将主目录所属人修改为本地用户vuser
4 [root@imxhy ~]# chmod u-w /home/ftptest01/
5 #新版vsftp不允许对主目录有w权限,否则无法登录,取消w权限。
6 [root@imxhy ~]# mkdir /home/ftptest01/pub #创建用户可上传的目录
7 [root@imxhy ~]# chown vuser:vuser /home/ftptest01/pub/ #将所属人改为vuser
8 [root@imxhy ~]# ll /home/
9 ……
10 dr-xr-xr-x. 2 vuser root 6 Aug 30 06:56 ftptest01
11 [root@imxhy ~]# ls -ld /home/ftptest01/pub/
12 drwxr-xr-x. 2 vuser vuser 6 Aug 30 07:15 /home/ftptest01/pub/
13 [root@imxhy ~]# systemctl restart vsftpd
14 [root@imxhy ~]# cd /home/ftptest01/
15 [root@imxhy ftptest01]# touch down.txt #创建用户测试文件
1 E:\Temp\ftp>ftp 192.168.10.10
2 连接到 192.168.10.10。
3 220 (vsFTPd 3.0.2)
4 用户(192.168.10.10:(none)): ftptest01
5 331 Please specify the password.
6 密码:
7 230 Login successful.
8 ftp> get down.txt
9 200 PORT command successful. Consider using PASV.
10 150 Opening BINARY mode data connection for down.txt (0 bytes).
11 226 Transfer complete.
12 ftp> put down.txt
13 200 PORT command successful. Consider using PASV.
14 553 Could not create file. #主目录不允许上传
15 ftp> cd pub
16 250 Directory successfully changed.
17 ftp> put down.txt
18 200 PORT command successful. Consider using PASV.
19 150 Ok to send data.
20 226 Transfer complete. #子目录下可上传