Install PureFTP:
aptitude install pure-ftpd-mysql
Create a table for virtual users:
CREATE TABLE `domains` (
`id` int(11) NOT NULL auto_increment,
`domain` varchar(255) NOT NULL,
`active` enum('0','1') NOT NULL default '0',
`password` varchar(64) NOT NULL,
`Uid` varchar(11) NOT NULL,
`Gid` varchar(11) NOT NULL,
`Dir` varchar(128) NOT NULL,
`ulbandwidth` smallint(5) NOT NULL default '125',
`dlbandwidth` smallint(5) NOT NULL default '125',
`ipaccess` varchar(15) NOT NULL default '*',
`quotasize` smallint(5) NOT NULL default '1000',
`quotafiles` int(11) NOT NULL default '100000',
PRIMARY KEY (`id`),
KEY `domain` (`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
Configure database settings in /etc/pure-ftpd/db/mysql.conf:
# MYSQLSocket /var/run/mysqld/mysqld.sock MYSQLServer 127.0.0.1 MYSQLPort 3306 MYSQLUser username MYSQLPassword password MYSQLDatabase database MYSQLCrypt md5 MYSQLGetPW SELECT password FROM domains WHERE domain="\L" AND active="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") AND password != '' MYSQLGetUID SELECT uid FROM domains WHERE domain="\L" AND active="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") AND password != '' MYSQLGetGID SELECT gid FROM domains WHERE domain="\L" AND active="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") AND password != '' MYSQLGetDir SELECT dir FROM domains WHERE domain="\L" AND active="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") AND password != '' MySQLGetBandwidthUL SELECT ulbandwidth FROM domains WHERE domain="\L" AND active="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") AND password != '' MySQLGetBandwidthDL SELECT dlbandwidth FROM domains WHERE domain="\L" AND active="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") AND password != '' MySQLGetQTASZ SELECT quotasize FROM domains WHERE domain="\L" AND active="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") AND password != '' MySQLGetQTAFS SELECT quotafiles FROM domains WHERE domain="\L" AND active="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") AND password != ''
Set configuration settings as shown below:
echo "clf:/var/log/pure-ftpd/transfer.log" > /etc/pure-ftpd/conf/AltLog echo "10" > /etc/pure-ftpd/conf/AnonymousBandwidth echo "yes" > /etc/pure-ftpd/conf/AnonymousCantUpload echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone echo "no" > /etc/pure-ftpd/conf/CreateHomeDir echo "50" > /etc/pure-ftpd/conf/MaxClientsNumber echo "16" > /etc/pure-ftpd/conf/MaxClientsPerIP echo "2000" > /etc/pure-ftpd/conf/MinUID echo "/etc/pure-ftpd/db/mysql.conf" > /etc/pure-ftpd/conf/MySQLConfigFile echo "yes" > /etc/pure-ftpd/conf/NoAnonymous echo "no" > /etc/pure-ftpd/conf/PAMAuthentication echo "/etc/pure-ftpd/pureftpd.pdb" > /etc/pure-ftpd/conf/PureDB echo "173 072" > /etc/pure-ftpd/conf/Umask echo "no" > /etc/pure-ftpd/conf/UnixAuthentication
Edit /etc/default/pure-ftpd-common and set to run as a standalone daemon as shown below:
STANDALONE_OR_INETD=standalone
Edit /etc/inetd.conf and disable FTP service:
# ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/pure-ftpd-wrapper
Afterwards, we restart Inetd and PureFTPd:
/etc/init.d/openbsd-inetd restart /etc/init.d/pure-ftpd-mysql restart
Now populate the database and test.
Run the following command to create or recreate the quota information for an account:
pure-quotacheck -d /var/www/example.com -u example.com
This may be necessary if the quota file is deleted, or if files are copied in to the user's directory via some other method than FTP, for example through the shell.
Subscribe to the RSS feed for Andy's Debian HOWTOs
Article from Andy's Debian HOWTOs (http://www.besy.co.uk/debian/debian)
Discussion