1 [root@imxhy~]# vi /etc/vsftpd/vsftpd.conf
2 anonymous_enable #允许匿名用户访问
3 anon_upload_enable #允许匿名用户上传(建立)普通文件
4 anon_mkdir_write_enable=YES #允许匿名用户建立目录
5 anon_umask #设置上传的默认文件权限(默认为600)
注意:匿名用户登陆后默认的主目录为:/var/ftp/
1 [root@imxhy ~]# ls -ld /var/ftp/
2 drwxr-xr-x. 3 root root 36 Aug 28 23:33 /var/ftp/
提示:由于主目录权限中其他人(ftp用户对此目录所属用户和所属组而言是其他人)不具有可读,因此无法上传文件。
1 [root@imxhy ~]# cd /var/ftp/
2 [root@imxhy ftp]# ls -l
3 total 0
4 drwxr-xr-x. 2 root root 6 Mar 31 23:12 pub
5 [root@imxhy ~]# chown ftp /var/ftp/pub #将匿名用户主目录下的pub目录所属人改为ftp,即让匿名用户可以在pub里上传
6 [root@imxhy ftp]# chown ftp /var/ftp/pub/
7 [root@imxhy ftp]# ls -l
8 drwxr-xr-x. 2 ftp root 6 Mar 31 23:12 pub #ftp已是pub目录的所属人,具备可读写执行权限
注意:
1:强烈不建议将主目录中其他人权限改为可读写且执行。
2:同时也不建议将/var/ftp/主目录所属人改为fpt(会报错)。
1 [root@imxhy ~]# service restart vsftpd #Centos6系列
2 [root@imxhy ~]# systemctl restart vsftpd #Centos7系列
1 E:\Temp>ftp 192.168.10.10
2 连接到 192.168.10.10。
3 220 (vsFTPd 3.0.2)
4 用户(192.168.10.10:(none)): anonymous
5 331 Please specify the password.
6 密码:
7 230 Login successful.
8 ftp> pwd
9 257 "/"
1 [root@imxhy ~]# cd /var/ftp/
2 [root@imxhy ftp]# touch anon_down.txt
3 ftp>ls
4 200 PORT command successful. Consider using PASV.
5 150 Here comes the directory listing.
6 anonymous.txt
7 pub
8 226 Directory send OK.
9 ftp: 收到 23 字节,用时 0.00秒 11.50千字节/秒。
10 ftp> get anonymous.txt
11 200 PORT command successful. Consider using PASV.
12 150 Opening BINARY mode data connection for anonymous.txt (0 bytes).
13 226 Transfer complete.
1 E:\Temp>ftp 192.168.10.10
2 连接到 192.168.10.10。
3 220 (vsFTPd 3.0.2)
4 用户(192.168.10.10:(none)): anonymous
5 331 Please specify the password.
6 密码:
7 230 Login successful.
8 ftp> cd pub #进入具备权限的目录(此前配置权限目录,而非主目录)
9 250 Directory successfully changed.
10 ftp> pwd
11 257 "/pub"
12 ftp> put anon_upload.txt
13 200 PORT command successful. Consider using PASV.
14 150 Ok to send data.
15 226 Transfer complete.