Ftp – pure-ftpd returns 550 Can’t change directory to /: Permission denied

ftppureftpd

I have pure-ftpd running onn ubuntu 16.04.5 LTS and have trouble uploading files. The server connects, but I can not create any directory nor can I upload files. It apears to be a permission problem.

The server is configured with virtual users over mysql, where each user has a directory. This used to work, but the config might have changed.

While trying to connect over 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

On the server site:

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

The mysql config file for pure-ftpd has this line:

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

Also I noticed that the .welcome message will not be displayed, not sure if this is also an indication.

Folder permissions are:

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

What could be the reason for this problem?

Best Answer

After hours of trying everything, I discovered the permissions of a parent directory was preventing the virtual user from reading their own home directory. Hint: If you're using the default chroot jail, then the home directory is reported as root (/).

Try verifying that the user can read all parent directories.

In my case...

There is a system user called ftpuser. Virtual user, bob, was created with uid as ftpuser, and home directory as something like /srv/ftp-home/bob. Example command: pure-pw useradd bob -u ftpuser -d /srv/ftp-home/bob

Well, /srv/ftp-home has to be owned by root in order for pure-ftpd to automatically create missing home directories, so ls -l on that directory was drwx------ 1 root root ...

I used chgrp ftpuser /srv/ftp-home and chmod g+rx /srv/ftp-home so that permissions were changed to drwxr-x--- 1 root ftpuser .... The user was able to log in after that.

I hope this saves someone several hours of head bashing.

Related Topic