www-data as chown but still remain write access as other user(s)

September 17, 2014 5k views

Hey all,

Currently I'm running a Wordpress multisite configuration. Here I've recursively set www-data as the owner of /var/www to allow Wordpress write access in it's whole installation. All folders within /var/www have their permissions set to 755. Now I'd like to still connect to my server using SFTP to add/edit/delete files using another (sudo) user, which isn't possible.

What would be presumed best practice to solve this problem? Thanks in advance!
Lorenzo

3 Answers

Hi,

you can create a new group

groupadd www-pub

add your (sudo) user and www-data to this group

usermod -a -G www-pub www-data
usermod -a -G www-pub username

change directory owner

chown -R www-data:www-pub /var/www

change permissions for the directory

chmod 2775 /var/www

the "prefix" 2 is a Set group ID bit, which causes the group to be copied to all new files and folders created in that folder. This does not work recursively, so you need to set it for existing folders manually

find /var/www -type d -exec chmod 2775 {} + # set directories to 2775
find /var/www -type f -exec chmod 0664 {} + # set files to 0664

Hi,

you can add your (sudo) user to the same group as www-data and then add read/write/execute permissions to the directory (775) for this group. Something like this: http://serverfault.com/a/65416

It works and allows you to create a file and all files created there from FTP is with username:www-pub but even after placing that file not allows you delete that file as in this case again it shows permission denied.

Any Suggestions

Have another answer? Share your knowledge.