ftp_home_dir off在rhel5下配置的ftp已经很久没有动过了,刚刚在捣鼓wordpress的时候发现ftp登不上了,先查看下防火墙:
[root@localhost lubinsu]# service iptables status
Firewall is stopped.
防火墙已经关闭了,看来不是这个问题。
额,root登录上去发现原来ftp不知道什么时候关闭了。
开起来=。=
service vsftpd start
问题又来了,这次报了另外一个错误:
C:\Users\snoopy>ftp 192.168.46.129
Connected to 192.168.46.129.
220 (vsFTPd 2.0.5)
User (192.168.46.129:(none)): lubinsu
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/home/lubinsu
500 OOPS: child died
Connection closed by remote host.看错误,明显是和目录有关的,RedHat默认安装了selinux,他是Linux内核中提供的强制访问控制系统,默认情况下没有开启对ftp的支持,所以不能dir等命令。可以通过命令getsebool -a|grep ftp来查看是否打开对ftp的支持,我们来检查下ftp的状态:
SELinux 的状态: sestatus -b | grep ftp[root@localhost lubinsu]# sestatus -b | grep ftp
allow_ftpd_anon_write off
allow_ftpd_full_access off
allow_ftpd_use_cifs off
allow_ftpd_use_nfs off
ftp_home_dir off
ftpd_disable_trans off
ftpd_is_daemon on
httpd_enable_ftp_server off
tftpd_disable_trans off很多都是off的,可以用以下命令打开:
[root@localhost lubinsu]# setsebool -P ftpd_disable_trans on在这里打开ftp_home_dir或者ftpd_disable_trans都可以,一个是切换支持切换目录而另外一个是支持传输的,或许你会更偏向于打开前者。ps:-P表示永久有效,不加的话只对当前状态有效,重启之后失效。最后重启下服务即可
C:\Users\snoopy>ftp 192.168.46.129
Connected to 192.168.46.129.
220 (vsFTPd 2.0.5)
User (192.168.46.129:(none)): lubinsu
331 Please specify the password.
Password:
230 Login successful.
ftp> put D:\latest.tar.gz
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 2229692 bytes sent in 0.06Seconds 39117.40Kbytes/sec.nice!