FTP server that sets user automatically..

Soldato
Joined
18 Jun 2003
Posts
4,368
Location
Rugeley
Hi all,
this so far has got me stumped, I'm just getting round to sorting out my new homeserver which is running Ubuntu 10.10 and I'm hitting a brick wall. Under Ubuntu the files in the www-data folder need to have permissions and users set to www-data else all sort of strange things happen, and I need an ftp server that will automatically do that for my user when I log in. Which one do you recommend or how do I go about it? Googled and failed to get a really good asnwer on this...

Cheers!
 
When you say all sorts of strange things happen, what do you mean? There is no requirement for the files to be owned by user:group of www-data:www-data. All that is required is that the user under which the webserver runs (www-data) have the appropriate permissions for the files and directories.

One solution to your problem might be to have all the files and directories group owned by www-data, who can read/write/execute as required. You could then set the setgid bit on the top level www folder such that any new files created are group owned by www-data.

In this way, the owner of the files and directories does not matter, and can be yourself, so you can have write permissions on all the files, whereas the webserver can't (good security practice).
 
Cheers...I've tried and failed to set the owner as www-data. Only way so far, is to chown -r manually....

I think I'm missing something somewhere...
 
It doesn't matter what the owner of the files is, only the group owner (in this method). If your www files are in /var/www, then:

If you were user "myself" on your machine, then:
$ chown -R myself:www-data /var/www

Will set the group owner to www-data and the owner to yourself.

You then need to ensure that the group permissions for the files are acceptable for the webserver. For the most part, this means read permission for files and execute permission for directories:
$ chmod -R g+rX /var/www

Then set the setgid bit on the /var/www folder so that any new folders or directories created inside have the www-data group owner automatically.
$ find . -type d | xargs chmod g+s

I think that should sort it.

Warning: I haven't tested any of this!
 
Last edited:
I would chroot FTP users to their home directory and set permissions to something like this:

2467zmf.png


2enrg35.png
 
It appears I've overlooked the fact that normal convention is to use a per-user subdirectory named 'public_html' rather than 'www' as I depicted above. Functionality can be enabled by using the appropriate mod for your chosen httpd (a2enmod with apache2 / lighttpd-enable-mod with lighttpd) to make content available at http://server/~username without manually creating the symlinks.
 
Last edited:
So, I'd set up the ftp server to place the files in public_html, how do I make that per user?

I've never really delved into ubuntu this much as it's just a homeserver, but I'm determined to get it sorted :-)
 
3dcandy said:
So, I'd set up the ftp server to place the files in public_html, how do I make that per user?

By ensuring each user has a public_html directory...

29lxlop.png


I hope I've actually got the right grasp of what you are trying to do here :confused:
 
So is it sorted?.. have you got any web-facing content for us to see? :)

And are you only FTPing around your private LAN or are you uploading files & documents to your home server from a remote connection as well?
 
it's erm...ok! It's a private dev server for my wordpress work mainly....

I've spent the last few weeks on a project for a christian conference which has to work on ie 5.5 so I can show you the link but be amazed by the basicness of it!

www.tarsusfellowship.co.uk
 
Back
Top Bottom