无法在centos 6上显示来自vsftpd服务器的文件
Posted
技术标签:
【中文标题】无法在centos 6上显示来自vsftpd服务器的文件【英文标题】:Can't display files from a vsftpd server on centos 6 【发布时间】:2015-06-04 22:18:29 【问题描述】:这是一个运行 apache 服务器和 vsftpd 服务器的 Centos 6。问题不在于连接,而在于显示 local_root 目录中的文件夹。
这里是 /etc/vsftpd/vsftpd.conf :
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this ou$
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you w$
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do AS$
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=YES
ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
## Heading ##
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
chroot_local_user=YES
local_root=/var/www
user_sub_token=$USER
这是 / 文件夹中的 ls -l 输出:
[root@daniel /]# ls -l
total 98
dr-xr-xr-x. 2 root root 4096 2015-05-14 04:43 bin
dr-xr-xr-x. 5 root root 1024 2015-05-12 15:33 boot
drwxr-xr-x. 20 root root 3820 2015-06-05 02:30 dev
drwxr-xr-x. 103 root root 12288 2015-06-05 03:03 etc
drwxr-xr-x. 5 root root 4096 2015-05-08 06:54 home
dr-xr-xr-x. 11 root root 4096 2015-05-08 05:13 lib
dr-xr-xr-x. 9 root root 12288 2015-06-04 03:25 lib64
drwx------. 2 root root 16384 2015-05-08 04:13 lost+found
drwxr-xr-x. 2 root root 4096 2011-09-23 14:50 media
drwxr-xr-x. 2 root root 0 2015-06-05 02:29 misc
drwxr-xr-x. 2 root root 4096 2011-09-23 14:50 mnt
drwxr-xr-x. 2 root root 0 2015-06-05 02:29 net
drwxr-xr-x. 3 root root 4096 2015-05-08 05:13 opt
dr-xr-xr-x. 167 root root 0 2015-06-05 02:29 proc
dr-xr-x---. 10 root root 4096 2015-06-04 03:02 root
dr-xr-xr-x. 2 root root 12288 2015-05-24 03:34 sbin
drwxr-xr-x. 7 root root 0 2015-06-05 02:29 selinux
drwxr-xr-x. 2 root root 4096 2011-09-23 14:50 srv
drwxr-xr-x. 13 root root 0 2015-06-05 02:29 sys
drwxrwxrwt. 3 root root 4096 2015-06-05 03:28 tmp
drwxr-xr-x. 13 root root 4096 2015-05-08 05:04 usr
drwxr-xr-x. 22 root root 4096 2015-06-04 02:57 var
此文件夹显示在浏览器或 ftp 连接(ftp 192.168.1.10) 但 /var/www 不是:(.
还有 ls -l /var/www :
[root@daniel /]# ls -al /var/www
total 84
drwxrwxr-x+ 11 root root 4096 2015-06-04 05:32 .
drwxr-xr-x. 22 root root 4096 2015-06-04 02:57 ..
drwxrwxr-x+ 3 root root 4096 2015-05-22 06:09 site1.com
drwxrwxr-x+ 3 root root 4096 2015-05-22 05:30 site2.com
drwxrwxr-x+ 2 root root 4096 2015-06-02 05:59 cgi-bin
drwxrwxr-x+ 3 root root 4096 2015-05-20 05:55 error
drwxrwxr-x+ 2 root root 4096 2015-06-04 05:32 ftp
drwxrwxr-x+ 2 root root 4096 2015-05-22 03:55 html
drwxrwxr-x+ 3 root root 4096 2015-05-20 05:58 icons
drwxrwxr-x+ 3 root root 4096 2015-05-22 05:30 site3.com
drwxrwxr-x+ 2 root root 4096 2015-05-19 07:26 usage
还有用于 ftp 的 selinux bool:
[root@daniel /]# getsebool -a | 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 --> on
ftpd_connect_db --> off
ftpd_use_fusefs --> off
ftpd_use_passive_mode --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_use_cifs --> off
tftp_use_nfs --> off
抱歉这个问题太长了,但我试图公开解决这个问题所需的所有细节。
提前感谢您的帮助!
【问题讨论】:
请将您的问题移至Super User 或Server Fault。这里是off-topic。 【参考方案1】:您的问题的解决方案是:
setsebool -P allow_ftpd_full_access=1
在你的 vsFTPD 配置文件中:
• chroot_local_user = YES
• allow_writeable_chroot=YES
【讨论】:
是的,我同意!但它可以作为安全安全吗?我指的是允许所有用户完全访问服务器的任何文件? allow_writeable_chroot=YES 在我尝试重新启动 vsftpd 时返回此错误:为 vsftpd 启动 vsftpd:500 OOPS:配置文件中无法识别的变量:allow_writeable_chroot 只要确保没有类型allow_writeable_chroot=YES
它是 100% 工作的。在某些情况下,您可能需要尝试重新启动 vsftpd 一次或两次,应该没问题。以上是关于无法在centos 6上显示来自vsftpd服务器的文件的主要内容,如果未能解决你的问题,请参考以下文章