Score:1

How can I set permissions for www-data on NEW folders and files PERMANENTLY?

cn flag

Ubuntu 20.04 VPS

I've read multiple threads on this and still don't get it. I have an FTP user deanhh for ONE of multiple virtual hosts in apache2. There are other FTP users also, for other domains. Deanhh is the owner of his domain's folder. When he creates a folder or creates and uploads a file via FTP he is the owner of the folder/file. That's what I want.

BUT the file has no permissions on it for other. I set umask 0000 on the telnet command line yesterday. Everything worked fine. When deanhh uploaded a file via FTP it inherited the permissions of the folder. Now umask is back to 0022 so when he uploads a new file or creates a folder there are no permissions on it for other.

How do I set it so that when an FTP user creates a folder or uploads a NEW file, they retain ownership AND 'other' has the permissions that were set for 'other' on the folder the file was uploaded to - PERMANENTLY?

Score:2
in flag

The simplest way would be to edit the /etc/login.defs file. Here's how:

  1. SSH into the server
  2. Open the /etc/login.defs file with sudo:
    sudo {your editor of choice} /etc/login.defs
    
  3. Find the row that starts UMASK. It may be around line 155 and look like this:
    UMASK           022
    
  4. Change 022 to whatever value you prefer
  5. Save the file and exit

The next time a person connects to their account, be it SSH or FTP, the appropriate umask will be applied.

kristy1024 avatar
cn flag
I did this and just tested it. It didn't work. sudo nano /etc/login.defs UMASK 0000 I logged into FTP as the domain owner and uploaded a new file. ls -l /var/www/deanhh.com -rw------- 1 deanhh deanhh 842 Dec 19 14:59 page21.php
kristy1024 avatar
cn flag
I did this and just tested it. It didn't work. Telnet into VPS as root sudo nano /etc/login.defs UMASK 0000 Saved it and reopened just to make sure. I logged into FTP as the domain owner and uploaded a new file. Then command line: ls -l /var/www/deanhh.com -rw------- 1 deanhh deanhh 842 Dec 19 14:59 TestWrite.php It did not work. There are no permissions for user group or other. Owner group should have rw and other should have r permission. Please let me know how I can solve this problem.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.