pure-ftpd 返回 550 无法将目录更改为 /:权限被拒绝

pure-ftpd 返回 550 无法将目录更改为 /:权限被拒绝

我在 ubuntu 16.04.5 LTS 上运行 pure-ftpd,上传文件时遇到问题。服务器连接成功,但我无法创建任何目录,也无法上传文件。这似乎是权限问题。

服务器通过 mysql 配置了虚拟用户,每个用户都有一个目录。这曾经有效,但配置可能已更改。

尝试通过 filezilla 连接时:

Status:         Resolving address of ftp.example.com
Status:         Connecting to myip...
Status:         Connection established, waiting for welcome message...
Status:         Insecure server, it does not support FTP over TLS.
Status:         Logged in
Status:         Retrieving directory listing...
Status:         Directory listing of "/" successful
Status:         Resolving address of ftp.example.com
Status:         Connecting to myip...
Status:         Connection established, waiting for welcome message...
Status:         Insecure server, it does not support FTP over TLS.
Status:         Logged in
Status:         Starting upload of /Users/user/Desktop/test.vcf
Command:    CWD /
Response:   550 Can't change directory to /: Permission denied
Command:    MKD /
Response:   550 Can't create directory: File exists
Command:    CWD /
Response:   550 Can't change directory to /: Permission denied
Command:    SIZE /test.vcf
Response:   550 Can't check for file existence
Command:    TYPE I
Response:   200 TYPE is now 8-bit binary
Command:    PASV
Response:   227 Entering Passive Mode (myip)
Command:    STOR /test.vcf
Response:   553 Can't open that file: Permission denied
Error:          Critical file transfer error

在服务器站点上:

Feb 12 14:18:33 fx pure-ftpd: ([email protected]) [INFO] Logout.
Feb 12 14:18:33 fx pure-ftpd: ([email protected]) [INFO] New connection from 199.203.151.209
Feb 12 14:18:33 fx pure-ftpd: ([email protected]) [INFO] stangeimmo is now logged in
Feb 12 14:19:34 fx pure-ftpd: ([email protected]) [INFO] Can't change directory to /: Permission denied
Feb 12 14:19:34 fx pure-ftpd: ([email protected]) [ERROR] Can't create directory: File exists
Feb 12 14:19:34 fx pure-ftpd: ([email protected]) [INFO] Can't change directory to /: Permission denied
Feb 12 14:19:35 fx pure-ftpd: ([email protected]) [ERROR] Can't open that file: Permission denied

pure-ftpd 的 mysql 配置文件有以下行:

MYSQLGetDir     SELECT CONCAT('/mnt/project/data/ftp-upload/', user) AS Dir FROM ftp_access WHERE User="\L"

我还注意到 .welcome 消息不会显示,不确定这是否也是一个迹象。

文件夹权限为:

rwxrwx--- 218 www users  4096 Feb 12 13:14 ftp-upload/

造成这个问题的原因可能是什么?

答案1

经过几个小时的尝试,我发现父目录的权限阻止虚拟用户读取他们自己的主目录。提示:如果您使用默认的 chroot jail,则主目录将被报告为 root (/)。

尝试验证用户是否可以读取所有父目录。

就我而言...

有一个名为 的系统用户ftpuser。虚拟用户 ,bob其 uid 为ftpuser,主目录为/srv/ftp-home/bob。示例命令:pure-pw useradd bob -u ftpuser -d /srv/ftp-home/bob

好吧,/srv/ftp-home必须由 root 拥有,以便 pure-ftpd 自动创建缺少的主目录,因此ls -l该目录是drwx------ 1 root root ...

我使用了chgrp ftpuser /srv/ftp-homechmod g+rx /srv/ftp-home以便将权限更改为drwxr-x--- 1 root ftpuser ...。此后用户就可以登录了。

我希望这可以为某些人节省几个小时的头脑风暴。

相关内容