在Linux环境中使用vsftpd搭建ftp实现匿名上传详细配置
关于在linux下搭建VSFTP下匿名不能上传的问题:
在/etc/vsftpd/vsftpd.conf(vsftpd的核心配置文件)中
配置如下:
anonymous_enable=YES(允许匿名访问)
anon_upload_enable=YES (允许匿名上传)
anon_mkdir_write_enable=YES(允许匿名创建文件)#如果不需要可为NO或者注释掉,保存退出。
在终端里输入如下:
[root@localhost ~]# ll -d /var/ftp
drwxr-xr-x 3 root root 4096 03-22 14:09 /var/ftp
[root@localhost ~]# mkdir /var/ftp/student(student是自己新建的文件夹,在var/ftp里默认有个pub文件夹)
[root@localhost ~]# ll -d /var/ftp/student/
drwxr-xr-x 2 root root 4096 03-22 15:10 /var/ftp/student/
[root@localhost ~]# chown ftp /var/ftp/student/
[root@localhost ~]# ll -d /var/ftp/student/
drwxr-xr-x 2 ftp root 4096 03-22 15:10/var/ftp/student/
[root@localhost ~]# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
allow_tftp_anon_write --> off
ftp_home_dir --> off
ftpd_disable_trans --> on
ftpd_is_daemon --> on
httpd_enable_ftp_server --> off
tftpd_disable_trans --> off
[root@localhost ~]# setsebool -P allow_ftpd_anon_write
Usage: setsebool [ -P ] boolean value | bool1=val1 bool2=val2...
[root@localhost ~]# setsebool -P allow_ftpd_anon_write on
[root@localhost ~]# getsebool -a | grep ftp
allow_ftpd_anon_write --> on
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
allow_tftp_anon_write --> off
ftp_home_dir --> off
ftpd_disable_trans --> on
ftpd_is_daemon --> on
httpd_enable_ftp_server --> off
tftpd_disable_trans --> off
[root@localhost ~]# ls -Zd /var/ftp/student
drwxr-xr-x ftp root root:object_r:public_content_t /var/ftp/student
[root@localhost ~]# chcon -t public_content_rw_t /var/ftp/student
[root@localhost ~]# ls -Zd /var/ftp/student/
drwxr-xr-x ftp root root:object_r:public_content_rw_t /var/ftp/student/