VSFTPD如何在chroot中chroot用户/ home?

我需要chroot所有本地用户到他们的主目录,但一个用户应该有权访问所有的用户目录。 如果我把admin_user放在chroot_list_file他可以访问整个文件系统。 我想限制他的访问只能到/home ,但是当他login到ftp服务器时,他的默认目录应该是/home/admin_user 。 怎么能做到这一点? 我有vsftpd安装以下configuration:

 # /etc/vsftpd/vsftpd.conf anonymous_enable=NO local_enable=YES write_enable=YES local_umask=002 dirmessage_enable=YES xferlog_enable=YES dual_log_enable=YES connect_from_port_20=YES xferlog_std_format=YES chroot_local_user=YES chroot_list_enable=YES chroot_list_file=/etc/vsftpd/chroot_list listen=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES max_clients=0 max_per_ip=0 # /etc/vsftpd/chroot_list admin_user 

您可以使用VSFTP的chroot()function来限制用户到他们的主目录,或不。

如果你不这样做,那么整个文件系统都是暴露的,你只能依靠具有正确的文件系统权限来保护你的非公开数据。

话虽如此,vsftp确实有一个select(有点)用deny_file指令来限制用户的移动:

  deny_file This option can be used to set a pattern for filenames (and directory names etc.) which should not be accessible in any way. The affected items are not hidden, but any attempt to do anything to them (download, change into directory, affect something within directory etc.) will be denied. This option is very simple, and should not be used for serious access control - the filesystem's permissions should be used in preference. However, this option may be useful ... ... 

创builddeny_file例如ls -d /*/ |grep -v home > /etc/vsftpd/forbidden_path

最好限制deny_file所以它只适用于你的admin_user而不是所有的用户:

user_config_dir=/etc/vsftpd/user.overrides/指令添加到主vsftpd.confconfiguration中,并创build用户特定的覆盖:

 # /etc/vsftpd/user.overrides/admin_user # admin_user is excluded from chroot() but restrict his access to /home deny_file=/etc/vsftpd/forbidden_path 

并重新启动FTP服务器,并testing行为是否如预期。