1

I have created a ftp user called " ftp_user " but whenever something is uploaded or created via this user, the permission becomes 600 and the group owner also changes to ftp_user

This makes it unreadable for the www-data user ( web server user ) I have to fix the permissions and ownership to be read by www-data manually each time

I want the permission to be 755 or 777 and the group owner to remain as www-data so that the www-data user can still access the files

Below newfile is a file created by the ftp_user

-rwxrwxrwx  1 ftp_user www-data         1646 Sep  2 18:58 artisan
-rwxrwxrwx  1 ftp_user www-data          503 Sep  2 18:58 gulpfile.js
-rwxrwxrwx  1 ftp_user www-data          567 Sep  2 18:58 server.php
drwxrwxrwx  2 ftp_user www-data         4096 Sep  2 18:58 tests
-rwxrwxrwx  1 ftp_user www-data          449 Sep  6 12:41 User.php
drwxrwxrwx  3 ftp_user www-data         4096 Sep 22 19:06 bootstrap
drwxrwxrwx  2 ftp_user www-data         4096 Jan 26 15:06 blog
-rwxrwxrwx  1 ftp_user www-data         1357 Jan 26 15:06 composer.json_23nov_16
-rwxrwxrwx  1 ftp_user www-data         1389 Jan 26 15:06 composer.json
-rwxrwxrwx  1 ftp_user www-data         1317 Jan 26 15:06 cc
-rwxrwxrwx  1 ftp_user www-data           67 Jan 26 15:06 info.php
drwxrwxrwx 10 ftp_user www-data         4096 Jan 26 15:06 app
drwxrwxrwx 12 ftp_user www-data         4096 Jan 26 15:06 public
drwxrwxrwx  2 ftp_user www-data         4096 Jan 26 15:06 config
-rw-------  1 ftp_user ftp_user      0 Jan 30 15:26 newfile

Does anyone has a solution ? Thanks in advance !

1
  • This may depend entirely on the FTP Server you're using. Commented Jan 30, 2017 at 19:21

1 Answer 1

1

The easiest solution is probably changing the directory where files are being created to be group-owned by "www-data" and setting the g+s bit on it; i.e.

chgrp www-data /path/to/data
chmod g+s /path/to/data

All files created under /path/to/data will be group-owned by www-data. Note that if files are being created in subdirectories, you'll also need to set the g+s bit on those subdirectories. You can the the group setgid bit on directories recursively using

 find /path/to/data -type d -exec chmod g+s {} +

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .