vsftpd匿名服务器

  • 匿名用户就是ftp,想要匿名用户写入,必须文件夹的权限为ftp可写。
  • 匿名用户的根目录不允许写,所以根目录的权限绝对不能是ftp可写和其他用户可写,如果根目录所有者为ftp的话,所有者的权限也不能写。

所以解决方法是建个单独的public文件夹用于上传文件,设置其为ftp可写或”其他用户可写“

还可建个download文件夹只用于下载,设置其他用户没有写权限便可。

假设要设定 /path/to/ws 为匿名用户的根目录, vsftpd有如下权限要求

ws                #drwxr-xr-x 3 root root  根目录不能有任何用户可写(root除外)
└── public    #drwxrwxrwx 2 ftp ftp  作为上传目录,必须要给ftp用户写权限, 干脆就777了

配置文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#FTP处于独立启动模式
listen=YES
listen_port=2121
anonymous_enable=YES
#是否允许本地用户访问
local_enable=YES
#允许本地用户访问时,是否允许他们有写入的权限
write_enable=YES
#本地用户新文件的umask (file:644 dir:755)
local_umask=022
#anonymous的
anon_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_world_readable_only=NO
#允许删除?
#anon_other_write_enable=YES
anon_root=/path/to/ws
#使用者进入某个目录时是否显示由message_file指定的文件内容

dirmessage_enable=YES
pasv_min_port=40000
pasv_max_port=50000

另外配置文件本身权限也有要求(man vsftpd):

An optional configuration file or files may be given on the command line. These files must be owned as root if running as root.