3

I want the user and group ownership of the files/dirs uploaded/created via ftp to be set to some user and group of my choice automatically. So far I think this is not possible (I'm using vsftp on Ubuntu). Insights ?

1
  • Do you remember how you ended up solving this in the end?
    – Joost
    Aug 16, 2015 at 18:25

1 Answer 1

3

You can use sticky bit on directory which affects ownership of newly created files and directories. And combine with umask, which will create new files with certain permissions.

Update after comment:

Group sticky bit on directory will overwrite group ownership of newly created files within this directory no matter in which group is user who creates this file. Umask can alter the permisions upon creation.

Classic usage of this combination is when you have "public" directory where every user can create/update/delete every file. So users has to by in same group ("users") and group rights has to by "rw" for files and "rwx" for directories. In this case, you will set on the parent directory sticky bit for group and change the group to "users". Then you have to set umask in system thru which the files will be uploaded (FTP, Samba,...). This umask should create files with rights 660 and directories with rights 2770.

Another usage - FTP. User has to have full access to files via FTP and yet Web server has to have read and even write access to some files. In this case you will set group sticky bit on document root of that web and change the group to www-data (for Apache). Than change access rights to 640 for files and 2750 for directories. For directories where www-data needs write access the rights will be 2770. In FTP server set umask to create files and directories with rights mention upon. Result? Uploaded files will have owner of given user, group www-data and least necessary rights.

I'm not sure what is your use case exactly, but changing of owner shouldn't have to be necessary and I personally like to know who created that file (Owner can change it but how many users know how to do that?)

1
  • would you please elaborate? As far as I know, sticky bit on dirs is about preventing users other than root and owner to unlink/rename the contents of the dir and umask is about limiting the permissions upon creation. I can't see how these will lead to a solution in my situation. Tnx. Jan 24, 2011 at 8:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .