Pureftpd dengan Virtual Account

Pureftpd adalah sebuah ftp server yang berjalan di unix-based (atau linux) system.

Di sini akan dibahas mengenai Pureftpd untuk membuat virtual hosting

sudo apt-get install mysql-server mysql-client pure-ftpd-mysql
sudo groupadd -g 2001 ftpgroup
sudo useradd -u 2001 -s /bin/false -d /bin/null -c "pureftpd user" -g ftpgroup ftpuser
mysql -u root -p
CREATE DATABASE pureftpd;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost' IDENTIFIED BY 'ftpdpass';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost.localdomain' IDENTIFIED BY 'ftpdpass';
FLUSH PRIVILEGES;
USE pureftpd;
CREATE TABLE ftpd (
`User` varchar(16) NOT NULL DEFAULT '',
`status` enum('0','1') NOT NULL DEFAULT '0',
`Password` varchar(64) NOT NULL DEFAULT '',
`Uid` varchar(11) NOT NULL DEFAULT '-1',
`Gid` varchar(11) NOT NULL DEFAULT '-1',
`Dir` varchar(128) NOT NULL DEFAULT '',
`ULBandwidth` smallint(5) NOT NULL DEFAULT '0',
`DLBandwidth` smallint(5) NOT NULL DEFAULT '0',
`comment` tinytext NOT NULL,
`ipaccess` varchar(15) NOT NULL DEFAULT '*',
`QuotaSize` smallint(5) NOT NULL DEFAULT '0',
`QuotaFiles` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`User`),
UNIQUE KEY User (User)
) TYPE=MyISAM;
quit;

Edit /etc/pure-ftpd/db/mysql.conf. It should look like this:

cp /etc/pure-ftpd/db/mysql.conf /etc/pure-ftpd/db/mysql.conf_orig
cat /dev/null > /etc/pure-ftpd/db/mysql.conf
vi /etc/pure-ftpd/db/mysql.conf
MYSQLSocket      /var/run/mysqld/mysqld.sock
#MYSQLServer     localhost
#MYSQLPort       3306
MYSQLUser       pureftpd
MYSQLPassword   ftpdpass
MYSQLDatabase   pureftpd
#MYSQLCrypt md5, cleartext, crypt() or password() - md5 is VERY RECOMMENDABLE uppon cleartext
MYSQLCrypt      md5
MYSQLGetPW      SELECT Password FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetUID     SELECT Uid FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetGID     SELECT Gid FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetDir     SELECT Dir FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTASZ   SELECT QuotaSize FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTAFS   SELECT QuotaFiles FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

Then create the file /etc/pure-ftpd/conf/ChrootEveryone which simply contains the string yes:

echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone

This will make PureFTPd chroot every virtual user in his home directory so he will not be able to browse directories and files outside his home directory.

Also create the file /etc/pure-ftpd/conf/CreateHomeDir which again simply contains the string yes:

echo "yes" > /etc/pure-ftpd/conf/CreateHomeDir

This will make PureFTPd create a user’s home directory when the user logs in and the home directory does not exist yet.

Finally create the file /etc/pure-ftpd/conf/DontResolve which again simply contains the string yes:

echo "yes" > /etc/pure-ftpd/conf/DontResolve

This will make that PureFTPd doesn’t look up host names which can significantly speed up connections and reduce bandwidth usage.

Afterwards, we restart PureFTPd:

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

Disarikan dari: http://www.howtoforge.com/virtual-hosting-with-pureftpd-and-mysql-incl-quota-and-bandwidth-management-on-ubuntu-9.10

Leave a comment

3 Comments.

  1. yeah dude, this post make me come!!!

  2. Is there something wrong with the CSS here? Everything looks yellow and I can barely read the page?

Leave a Reply


[ Ctrl + Enter ]