I have been following this solution, this solution, and this solution. All of these solutions suggest to change DIR_MODE=0755 to DIR_MODE=0750 to prevent newly added users to be accessed by other users. I went ahead and changed DIR_MODE=0750 using sudo vim /etc/adduser.conf and save the file. Now, I expect new users have only permission set to 750. When I created user1 using sudo useradd -m user1, the home directory of the user1 still has 755 or drwxr-xr-x permission. I check using ls -ld /home/user1 and get drwxr-xr-x 2 user1 user1 4096 Jun 2 04:38 user1.
I can do chmod for this user but I want this to be done automatically.
I do not want to use umask because it sets the permission globally on the file system and not only for the user home directory. Also, this solution does not support it.
What am I mission and what is wrong with my solution?
Note1:
I am doing all the above in VM on GCP and use ubuntu 18.
Note2:
I am adding a user using useradd command and adding user using adduser works fine. I want to do it using useradd not useradd.