Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9316651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:40:32+00:00 2026-06-19T02:40:32+00:00

I’m setting up a shared hosting. My users have SFTP access to the server

  • 0

I’m setting up a shared hosting. My users have SFTP access to the server to upload their contents. I’m using separate PHP processes running as respective users (one per site). I want the users to not see other users’ contents by default (except via the web server as any other unprivileged client), but the web server (running as www-data user/group) should be able to read everything. Right now I’m giving the ownership of files in www to particular users and group ownership to www-data and using the set GID bit to propagate the group ownership to new files/directories (users are not in www-data group).

It worked fine, but now I’m facing a problem. Some of the sites are using wordpress and when they upload files the set GID bit is lost meaning that the web server has no access to it. Is there some way to configure either PHP or wordpress (more likely) to chmod files and directories into the right permissions?

Note: I’m not using safe mode in PHP, so it should be able to add the set GID bit.

Update: I’ve tried tweaking the FS_CHMOD_DIR and FS_CHMOD_FILE values in wordpress config. I assumed that this would allow me to chmod the uploaded files to whatever I wanted. However, it did not affect the permissions of newly uploaded files. From the info in codex I guess these settings apply to core update function only.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T02:40:33+00:00Added an answer on June 19, 2026 at 2:40 am

    This is not the answer to the exact question, but rather a solution to the problem in general. Assign the ownership of user’s web directory to user/www-data and set the permissions to 750, no SGID bit. Users must not belong to the www-data group. However, inside that directory the group ownership can be set to the users’ main group (e.g. users). The permissions inside can be 644 and 755 for files and subdirectories respectively. The security is provided by the fact that other users will not be able to enter or traverse this web directory and therefore will not be able to access any files inside even though they have enough permissions to access the files themselves. This will restrict both users connecting via SFTP and executing PHP commands.

    Since this solution does not use the set GID bit it solves the original issue. Uploaded files can be left with their default ownership and permissions.

    A little demonstration:

    transistor# mkdir www
    transistor# chown :www-data www
    transistor# chmod 750 www
    transistor# ls -l
    total 4
    drwxr-x--- 2 root www-data 4096 Feb 20 20:59 www
    transistor# touch www/file1.txt
    transistor# mkdir www/subdir
    transistor# touch www/subdir/file2.txt
    transistor# ls -l www
    total 4
    -rw-r--r-- 1 root root    0 Feb 20 21:00 file1.txt
    drwxr-xr-x 2 root root 4096 Feb 20 21:00 subdir
    transistor# ls -l www/subdir 
    total 0
    -rw-r--r-- 1 root root 0 Feb 20 21:00 file2.txt
    transistor# exit
    giedrius@transistor:/tmp/sandbox$ cd www
    bash: cd: www: Permission denied
    giedrius@transistor:/tmp/sandbox$ ls www/subdir
    ls: cannot access www/subdir: Permission denied
    giedrius@transistor:/tmp/sandbox$ cat www/file1.txt
    cat: www/file1.txt: Permission denied
    giedrius@transistor:/tmp/sandbox$ cat www/subdir/file2.txt
    cat: www/subdir/file2.txt: Permission denied
    giedrius@transistor:/tmp/sandbox$ sudo -su www-data
    transistor% ls www 
    file1.txt  subdir
    transistor% cat www/file1.txt 
    transistor% cat www/subdir/file2.txt 
    transistor% 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.