错误消息“500 OOPS:vsftpd:拒绝在 chroot() 内使用可写根运行”- 使用户被监禁

Chr*_*ugh 28 webserver vsftpd 12.04

到目前为止,我一直无法将 FTP 用户关押在他们的网站目录中。是否有解决方案既可以修复此错误,又可以将用户关在他们的目录中?

我更改的 vsFTPd 设置:

listen_port=9000
Set: anonymous_enable=NO
Uncomment: local_enable=YES
Uncomment: write_enable=YES
Uncomment: local_umask=022
Set: connect_from_port_20=NO
Uncomment: idle_session_timeout=600
Uncomment: data_connection_timeout=120
Comment out: #ftpd_banner=Welcome to blah FTP service. [should be on line 104]
Added: banner_file=/etc/issue.net
Uncomment: chroot_local_user=YES
Uncomment: chroot_local_user=YES
Uncomment: chroot_list_enable=YES
Uncomment : chroot_list_file=/etc/vsftpd.chroot_list
Run Code Online (Sandbox Code Playgroud)

在文件末尾,我添加了:

# Show hidden files and the "." and ".." folders.
# Useful to not write over hidden files:
force_dot_files=YES

# Hide the info about the owner (user and group) of the files.
hide_ids=YES

# Connection limit for each IP address:
max_per_ip=10

# Maximum number of clients:
max_clients=5

# FTP Passive Settings
pasv_enable=YES
#If your listen_port is 9000 set this range to 7500 and 8500
pasv_min_port=[port range min]
pasv_max_port=[port range max]
Run Code Online (Sandbox Code Playgroud)

有问题的用户mybloguser被监禁在她/他的网站目录下,/srv/www/myblog并且该用户不是该nano /etc/vsftpd.chroot_list文件的一部分。用户的主目录也是/srv/www/myblog过去用来工作的。

我尝试了allow_writeable_chroot=YES无效的解决方案,实际上完全破坏了 vsFTPd。

我试过了:

我们如何才能修复此错误并将用户囚禁在其主目录中?

小智 27

对于 VSFTPD 3,

  1. 去: /etc/vsftpd.conf
  2. 并添加这个:

    allow_writeable_chroot=YES
    
    Run Code Online (Sandbox Code Playgroud)

    如果它还不存在,只需添加它。

  3. 重启 vsftpd 服务:

    service vsftpd restart
    
    Run Code Online (Sandbox Code Playgroud)

它应该工作。

  • 我在哪里可以阅读有关此选择的安全影响的信息? (6认同)
  • 提问者实际上表示他已经尝试过这个并且没有用,所以这不是他问题的答案。 (4认同)

小智 17

这个问题的真正解决方案:用户的主文件夹应该是可写的,只能是可读的。

所以,如果用户站点在文件夹中cat/example.com/http/,文件夹cat必须有chmod 555,一切都会好的。

  • 这是没有意义的。用户的目录不应该是可写的??? (14认同)
  • 如果用户不会写文件,他们究竟应该如何**上传**文件?! (8认同)
  • 这工作得很好!只需使用 chmod 555 为用户创建一个主页,然后在其中使用 chmod 755 或您需要的那个为网站(或多个网站)创建一个主页:一切正常,用户将拥有写入权限。 (7认同)

Chr*_*ugh 13

在进一步查看这篇文章后,在评论中发布了一个解决我问题的软件包。您可以通过我的名字或“标记”文档进行搜索:http : //www.benscobie.com/fixing-500-oops-vsftpd-refusing-to-run-with-writable-root-inside-chroot/。这是我如何进一步解决此问题的详细信息。

用户仍然被监禁在他们的家庭目录中!!!

# ------------------------------------------------------------------------------
# SETUP FTP USERS --------------------------------------------------------------
# ------------------------------------------------------------------------------

# create the ftp users and lock them to the website directories
useradd -d /srv/www/[website/appname] -m [ftp user name]

# set the ftp account passwords
passwd [ftp user name]

# add the ftp users to the www-data user/group
adduser [ftp user name] www-data

# BUG FIX: 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
sudo add-apt-repository ppa:thefrontiergroup/vsftpd
sudo apt-get update
sudo apt-get install vsftpd

# Edit the vsftpd.conf and append this setting to the end of the file to keep users' jailed!
nano /etc/vsftpd.conf

# add all of the text between the starting [[ and ending ]]
# [[

# Keep non-chroot listed users jailed
allow_writeable_chroot=YES

# ]]

# restart the service for changes to take effect
sudo service vsftpd restart

#test ftp via secondary terminal window:
ftp [ftp user name]@[server ipaddress] [ftp port]
Run Code Online (Sandbox Code Playgroud)

  • **请注意:** Chris 的解决方案会将第三方包服务器添加到您的存储库列表中!当您_盲目地_接受要在您的系统上安装的外国软件包时,为什么还要安装一个安全的 chrooted FTP 服务器。(克里斯:我不认为你会利用,但使用这个解决方案恕我直言是糟糕的系统管理) (12认同)
  • 该主题有 12'000 次浏览,假设 5% 使用您的解决方案并添加了您的存储库。您可以轻松添加集成后门的新版本核心包。一周内您就可以访问 600 个系统。我认为您不会这样做,但添加第三方存储库并不是很安全。 (2认同)

Rei*_*hin 8

根据之前的回答“这个问题的真正解决方案:用户的主文件夹不应该是可写的,只能是只读的。”。一般的想法是对的,但有一个错误的认识。

下面我将尝试举一个简单的例子:

首先,我们需要构建用户目录的拓扑:

 /home (ro)
   |-someuser (rw,700)
         |-ftp_upload (ro,555) - ch_rooting 在这里,需要 vsftpd 只读:(
           |-temp (rw,755)
           |-in_box (rw,755)
           |-out_box (rw,755)

vsftpd.conf 切:

# 启用 chroot
chroot_local_user=是

# chroot 除在 chroot_list 中监听的所有用户
chroot_list_enable=是

# 异常列表。理想情况下,它应该是空白的 ;)
chroot_list_file=/etc/vsftpd/chroot_list

# 将ftp根目录映射到特定目录
local_root=/home/someuser/ftp

此配置适用于单用户配置。对于多用户,应额外使用“user_config_dir”指令。

**更新 20/09

------**

这是棘手的解决方法,不是最好的使用方法,但是.... 如果您需要可写的 ftp 根文件夹,只需在启动前和启动后命令中插入权限更改命令。

  1. 预启动 - 将服务器要求的权限更改为只读(:

  2. 启动服务器

  3. 启动后 - 更改读写权限或您需要的权限。