Centos – FTP not showing files or directories

centosftpiptables

I'm able to log into FTP but I'm not seeing any files or folders.

My iptables looks like this

-A INPUT -p udp -m udp –dport ftp-data -j ACCEPT
-A INPUT -p udp -m udp –dport ftp -j ACCEPT
-A INPUT -p tcp -m tcp –dport https -j ACCEPT
-A INPUT -p tcp -m tcp –dport http -j ACCEPT
-A INPUT -p tcp -m tcp –dport ftp-data -j ACCEPT
-A INPUT -p tcp -m tcp –dport ftp -j ACCEPT

When I ftp to localhost from the server itself, I'm getting the following error:

230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> debug
Debugging on (debug=1).
ftp> ls
ftp: setsockopt (ignored): Permission denied

—> PASV
227 Entering Passive Mode (127,0,0,1,221,184)
—> LIST
150 Here comes the directory listing.
226 Directory send OK.
ftp>

Switching from passive to active gives me the same error:

ftp> passive
Passive mode off.
ftp> ls
ftp: setsockopt (ignored): Permission denied

—> PORT 127,0,0,1,233,166
200 PORT command successful. Consider using PASV.
—> LIST
150 Here comes the directory listing.
226 Directory send OK.
ftp>


Passive mode shouldn't work because I haven't opened or specified a port-ranage, but active mode should work with these settings right?

Update 1

Config file VSFTPD:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
listen=YES
log_ftp_protocol=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=NO

Another note: I log in with my own user to /home/user and can't see any folders. But when I cd to / the folders are displayed without error messages.

Best Answer

Per the comments, disabling SELinux seems to have solved the problem. I would suggest to now:

  1. Turn it back on with setenforce 1.
  2. Use ls -Z /path/to/ftp/home/folder to check the context of the directory you're trying to FTP into, and see if the context is "public_content_t"
  3. If not, use restorecon(8) to fix incorrect context, e.g. restorecon -R /path/to/ftp/home/folder