LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Vsftpd Virtual users upload/download (https://www.linuxquestions.org/questions/linux-newbie-8/vsftpd-virtual-users-upload-download-664045/)

graugeist 08-20-2008 08:03 AM

Vsftpd Virtual users upload/download
 
I have been looking for an answer to my question. Maybe I am not entering the right search string.
My Goal:
I would like to provide a site where my customer can upload files to my site. I make changes to their files and then place the file into the customer home directory for download. No anonymous login. Customer has usernames and passwords. Customers can not see the other customers home directory. And I do not want the customer listed as a local user.

I have already setup a FTP server (I am using VSFTPD and Ubuntu) with virtual users. (Following a lot of links.) I have most of it working the way I need. Virtual users login with their userID and password (they are Chroot to their home directory). And then download files that I place in their home directory (if I change the ownership on that file to the customer name or the group "virtual"). My problems is when the virtual users upload a file to a directory under their home directory called upload. My local user can not read the upload directory. And I do not want to use root to access the files.

I used a command "mkdir -m 2733 /home/ftpsite/username/upload" I like this command, due to the fact that this hides the files from the virtual users once they upload. I have tried adding the local user to the group "virtual", but this does not help with accessing the upload directory.

Can I change the file ownership as they are being upload by virtual users? I would like a certain local user to be able to access these files and not the virtual users. Sorry about being so long about this.

Do you any suggestion? I do not want the virtual users to share download directories. But they could share the upload directory.

timmeke 08-20-2008 11:10 AM

chroot prevents virtual users from getting into each other's home directories.
To allow a specific, real local user to access all the "upload" folders in the virtual users' home directories:
-create a group with only the real local user in it;
-chgrp the home directories & the upload folders so that they're owned by the group that was just created and make sure they're readable (r), writable (w) & accessible (x) for the group
-set the "setGID" permission bit on for the home directories & upload folders. This makes sure that newly added (uploaded) files are owned by the proper group.
-I think you can prevent virtual users from chmod just in case by using a vsftpd option to block certain commands, but have not tried that yet
-Set the umask option in the virtual user's config files to a proper value (ie including rw group access), for instance umask=007 (this gives newly uploaded files the inverse permission 770 or rwx for user&group, no permission for anyone else).

Group write permissions on the upload folders imply that you can use "mv" (or "cp") to change uploaded files (ie by changing their ownership to local user) that have wrong permission and would be unaccessible to the local user.
This can be done without root access.

graugeist 08-21-2008 08:46 AM

Thanks for your reply, I will give this a try. It might take a couple of days.

graugeist 08-22-2008 09:20 PM

Thanks for you help on this. I was able to use a couple of your suggestions (assigning local user to a group that no one else belongs to) and You also got me searching down the right road on rights of files and directory. (since I am a newbie) I now have a working drop box were virtual users are allowed to upload, but not read or see the file after upload. For upload files, changing the unmask to 007 was the key for me. My local was able to access the files. On the download, I can place files into their own directory and they are able to download the file, but not delete it. Once again thank you for your help.

timmeke 08-25-2008 01:29 AM

You're welcome, graugeist. That's what LQ Forums is for!


All times are GMT -5. The time now is 01:52 AM.