Virtual Hosting With PureFTPd And MySQL (Incl. Quota And Bandwidth Management) - Page 3

Want to support HowtoForge? Become a subscriber!
Submitted by falko (Contact Author) (Forums) on Sat, 2005-10-22 17:55. ::

5.1 Database Administration

For most people it is easier if they have a graphical front-end to MySQL; therefore you can also use phpMyAdmin (in this example under to administrate the pureftpd database.

Whenever you want to create a new user, you have to create an entry in the table ftpd so I will explain the columns of this table here:

ftpd Table:

  • User: The name of the virtual PureFTPd user (e.g. exampleuser).
  • status: 0 or 1. 0 means the account is disabled, the user cannot login.
  • Password: The password of the virtual user. Make sure you use MySQL's MD5 function to save the password encrypted as an MD5 string:
  • UID: The userid of the ftp user you created at the end of step two (e.g. 2001).
  • GID: The groupid of the ftp group you created at the end of step two (e.g. 2001).
  • Dir: The home directory of the virtual PureFTPd user (e.g. /home/ If it does not exist, it will be created when the new user logs in the first time via FTP. The virtual user will be jailed into this home directory, i.e., he cannot access other directories outside his home directory.
  • ULBandwidth: Upload bandwidth of the virtual user in KB/sec. (kilobytes per second). 0 means unlimited.
  • DLBandwidth: Download bandwidth of the virtual user in KB/sec. (kilobytes per second). 0 means unlimited.
  • comment: You can enter any comment here (e.g. for your internal administration) here. Normally you leave this field empty.
  • ipaccess: Enter IP addresses here that are allowed to connect to this FTP account. * means any IP address is allowed to connect.
  • QuotaSize: Storage space in MB (not KB, as in ULBandwidth and DLBandwidth!) the virtual user is allowed to use on the FTP server. 0 means unlimited.
  • QuotaFiles: amount of files the virtual user is allowed to save on the FTP server. 0 means unlimited.


6 Anonymous FTP

If you want to create an anonymous ftp account (an ftp account that everybody can login to without a password), you can do it like this:

First create a user ftp (with the homedir /home/ftp) and group ftp:

groupadd ftp
useradd -s /bin/false -d /home/ftp -m -c "anonymous ftp" -g ftp ftp

Then create the file /etc/pure-ftpd/conf/NoAnonymous which contains the string no:


With this configuration, PureFTPd will allow anonymous logins.

Restart PureFTPd:

/etc/init.d/pure-ftpd-mysql restart

Then we create the directory /home/ftp/incoming which will allow anonymous users to upload files. We will give the /home/ftp/incoming directory permissions of 311 so that users can upload, but not see or download any files in that directory. The /home/ftp directory will have permissions of 555 which allows seeing and downloading of files:

cd /home/ftp
mkdir incoming
chown ftp:nogroup incoming/
chmod 311 incoming/
cd ../
chmod 555 ftp/

Now anonymous users can login, and they can download files from /home/ftp, but uploads are limited to /home/ftp/incoming (and once a file is uploaded into /home/ftp/incoming, it cannot be read nor downloaded from there; the server admin has to move it into /home/ftp first to make it available to others).






Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Thu, 2011-06-30 20:07.

Here is web based user interface for Pure-FTPd+MySQL.

Submitted by Anonymous (not registered) on Sat, 2006-05-13 13:21.
If i recall setting UID and GID to 555 weill make the account a download only account. -Tortanick
Submitted by Anonymous (not registered) on Thu, 2006-05-18 13:52.
I double checked, they can't upload but they can delete existing files.
Submitted by myles (registered user) on Sat, 2005-12-24 01:29.
Great howto..!

I already had a userDB in MySQL for a SMTP-gateway and therefore didn't wanted to add too many columns in my table. If anyone else should have the same need, here is the SQL Join sentence for UID:
SELECT T1.UID FROM ftpd_users T1, common_users T2 WHERE T1.UserID = T2.UserID AND T2.username = "\L"
  • common_users contains username and password
  • ftpd_users contain UID,GID, bandwidth and etc...
Submitted by Anonymous (not registered) on Wed, 2005-11-02 14:36.

I remember there was a performance comparison between pureftpd and vsftpd and it concluded that the fomer was far worse than the latter. You may still google for the comparison result.

But that was one- or two-year old. How about the preformance improvement of pureftpd now? Anyone has an idea?

Submitted by Anonymous (not registered) on Wed, 2005-10-26 15:01.

In point 6 when trying to change "incoming" permissions with chown ftp:nogroup incoming, I have this error message:

chown: «ftp:nogroup»: usuario inválido

Submitted by Anonymous (not registered) on Tue, 2005-10-25 14:20.

Hi all i couldnt understand why my setup did not work if you are struggling i hope this sorts it out !!

debian# ftp localhost
Connected to debian.
Can't exec "/usr/sbin/pure-ftpd": No such file or directory
at /usr/sbin/pure-ftpd-wrapper line 174.
ftp> quit

I just add a symbolic link to pure-ftpd, because pure-ftpd-wrapper need
it to launch a binary named pure-ftpd.
debian# ln -s /usr/sbin/pure-ftpd-mysql /usr/sbin/pure-ftpd

Submitted by Anonymous (not registered) on Mon, 2005-10-24 22:46.

What about Pure-FTPD group support? Say I want to add user1 user2 and user3 to groupA. Is that possible? Simply adding them (comma seperated or not) to the GID field doesn't work.