==Setting up Pure-FTP with per user quotas. (FreeBSD 6.1)==
By Nathan Butcher 2006.12.6

We are setting up FTP service for users to upload their web content to their 
webpage directories. There's just one problem though... we want to limit the 
amount of disk space our clients have to do this. Apache certainly isn't going 
to create disk quotas. We'll have to implement quotas via our FTP daemon.

Normally I'd use vsftpd for FTP because it is the most secure, but it does lack all the nice features which Pure-FTPd has. 
Both of these FTP daemons are top notch IMHO, and secure enough if configured correctly.

---------------------------------------------------------------------

Installing from ports in FreeBSD

	# cd /usr/ports/ftp/pure-ftpd
	# make install

Note here that the defaults ports Makefile includes --with-everything, which includes pretty much all 
of the features possible (including quotas). The features it doesn't install
automatically appear in the ncurses display, so from there you can select what 
you need. We won't be using any databases for information though, 
although that is an install option. 
(I just left the ncurses install display alone)

PureFTPd installs and creates sample config files in /usr/local/etc/
Copy the sample config

	# cp pure-ftpd.conf.sample pure-ftpd.conf

You can adjust this how you see fit, and kick start the ftp daemon quite easily with:-

	# /usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf

Pure-ftpd can be easily started with command line arguments, but it's much easier to use the PERL (or python) 
script to do the option parsing work for you. Pure-ftpd has a heck of a lot of
command line options - which is one of its strengths.

**************

Make a user account to handle all the virtual users. (ftpgroup and ftpuser are good options)

	# pw groupadd ftpgroup
	# pw useradd ftpuser -g ftpgroup -d /home/ftpuser -s /etc

The "pure-pw" command handles administration quite well. To create a test user
input the following. Note how (-u) selects which system user to operate under. 
Keep in mind that (-d) chroots the user to the specified directory (there is a
-D option which doesn't chroot, but is a security risk of course)
The (-m) switch is also good to use, because it forces the command to
automatically build your changes into the hash (automatically triggering mkdb)

	# pure-pw useradd testuser -m -u ftpuser -d /home/ftpuser

Speaking of which, once this has been done, you need to create a hashed db for the ftp daemon to use. 
(Otherwise you'll find that you can't log on with your new user). 
Do the following:-

	# pure-pw mkdb

This adds an entry into the virtual users file table (/usr/local/etc/pureftpd.passwd).
Format for the virtual users file is as follows. The colon acts as a seperator, 
so it should be easy to parse if you wish to write your own scripts.
In many ways, the file format mimics that of ProFTPd, but with extra 
information 
(except that ProFTPds shell section is where PureFTPd's upload bandwidth section is). 
This is useful to know when migrating from one FTP daemon to another 
(usually away from ProFTPD!).

[account]:[password]:[uid]:[gid]:[gecos]:[home directory]:[upload
bandwidth]:[download bandwidth]:[upload ratio]:[download ratio]:[max number
of connections]:[files quota]:[size quota]:[authorized local IPs]:[refused
local IPs]:[authorized client IPs]:[refused client IPs]:[time
restrictions]

You will almost certainly need to adjust your pure-ftpd configuration file to 
point to /usr/local/etc instead of just /etc to find the pureftpd.pdb

	# vi /usr/local/etc/pure-ftpd.conf
	--------------------------------------
	PureDB			/usr/local/etc/pureftpd.pdb
	--------------------------------------

You may want to automatically create user directories when they first log in
(saves you doing it manually)

	# vi /usr/local/etc/pure-ftpd.conf
	--------------------------------------
	CreateHomeDir		yes
	--------------------------------------	

********************

Notes when using Debian:

The PureFTPd package configuration works differently than the plain source version. 
(Have a look in /etc/pure-ftpd/conf) 
Here you will find all the options - except that they exist as individual 
files,all which contain the desired setting. Edit those to configure PureFTPd.

Hosted by www.Geocities.ws

1