结果测试的时候发现

ftp localhost

ftp> cd cdrom

550 Failed to change directory.

无法切换目录到/pub/cdrom

原因是SElinux的FTP传输审核功能禁止切换目录

解决办法:

1. /etc/sysconfig/selinux上禁用之,重启Linux生效

2. 不重启linux,临时停用selinux的办法,

/usr/sbin/setenforce 0

3. 禁用SElinux的FTP传输审核功能

/usr/sbin/setsebool -P ftpd_disable_trans 1

service vsftpd restart

其中参数 -P表示永久性生效

使用getsebool -a | grep ftp命令找到ftp的bool值

匿名上传setsebool -P allow_ftpd_anon_write on

禁用ftp传输审核setsebool -P ftpd_disable_trans on

sestatus

[root@xen ~]# sestatus

SELinux status: enabled

SELinuxfs mount: /selinux

Current mode: permissive

Mode from config file: enforcing

Policy version: 21

Policy from config file: targeted

[root@xen ~]# 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 --> off

ftpd_is_daemon --> on

httpd_enable_ftp_server --> off

tftpd_disable_trans --> off

[root@xen ~]# setsebool -P ftpd_disable_trans on

[root@xen ~]# service vsftpd restart

------------------------------------------------

如果问题依旧,再尝试如下的方法:

打开 /etc/vsftpd/vsftp.conf,将

# users to NOT chroot().

chroot_list_enable=YES

改成

# users to NOT chroot().

chroot_list_enable=NO

并把ftp用户添加到/etc/vsftpd/chroot_list中

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐