Force group assignment in chrooted sftp environment

chownchrootmountsftp

I've got the following setting:

There are several users /home/user1, /home/user2, and so on. Additionally there is a user /home/sftp-all. The folder /home/sftp-all/shared is mounted in every other users /home directory, e.g. /home/user1/shared.
All users user1,user2,…,sftp-all are members of a group called 'sharegroup'.

Now the problem is, if one of these users (user1,…) writes into that folder, the new file is owned by the user and his primary group (e.g. user1:user1,..). Instead, i want it to be owned by user1:sharegroup.
Any ideas how to solve this? Thank you in advance!

Best Answer

You should look into using ACL permissions on the filesystem. You can set a "default" permission, and you can have multiple groups, users, etc.

https://help.ubuntu.com/community/FilePermissionsACLs

See the answer to this other post for more info:

https://superuser.com/questions/381416/forcing-group-and-permissions-for-created-file-inside-folder