how to install pure-FTPd (1) ============================ 1. download the latest version wget ftp://ftp.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.26.tar.gz 2. unzip it tar zxvf pure-ftpd-1.0.26.tar.gz 3. cd to the dir cd pure-ftpd-1.0.26 4. configure it sudo ./configure --with-mysql --with-cookie --with-throttling --with-ratios --with-quotas --with-puredb --with-ftpwho sudo ./configure --with-mysql --with-cookie --with-throttling --with-ratios --with-quotas --with-ftpwho 5. compile it sudo make 6. check to see if compile was successfull sudo make check 7. install it sudo make install ************************************************************* how to configure pure-FTPd with virtual users and pure-ftpd database(2) ======================================================================= 1. create those files: sudo nano /etc/pureftpd.pdb (sudo nano /etc/pure-ftpd/pureftpd.pdb) sudo nano /etc/pureftpd.passwd 2. create a new system group "ftpgroup" group and an "ftpuser" user. sudo groupadd ftpgroup sudo useradd -g ftpgroup -d /dev/null -s /etc ftpuser <2> Now create our FTP users sudo pure-pw useradd NAME -u ftpuser -d /DIRECTORY example: sudo pure-pw useradd ftpfang -u ftpuser -g ftpgroup -d /media/newDisk500GB/ftpfang -N 10 sudo pure-pw useradd ftplei -u ftpuser -d /media/newDisk500GB sudo pure-pw useradd ftpfang -u ftpuser -d /media/newDisk500GB sudo pure-pw useradd lei -u ftpuser -d /media/newDisk500GB/fileServer sudo pure-pw useradd fang -u ftpuser -d /media/newDisk500GB/fileServer/SHARE (By default your users will be saved in /etc/pureftpd.passwd) <3> update the pureftpd-Database sudo pure-pw mkdb <4> To get user details: sudo pure-pw list or: sudo pure-pw show lei <5> DELETING USERS: sudo pure-pw userdel lei123 <6> reset password for a user: sudo pure-pw passwd ftpfang (update your database after it: sudo pure-pw mkdb) 7. Create the database and make sure that the pure-ftpd configuration strictly uses the pdb file for managing accounts: sudo ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/PureDB sudo nano /etc/pure-ftpd/conf/PAMAuthentication (Change yes into no) Note: in the file /etc/pure-ftpd/conf/PureDB i had to change the path to: /etc/pureftpd.pbd 8. start the server sudo /etc/init.d/pure-ftpd stop sudo /usr/local/sbin/pure-ftpd -j -E -b -l puredb:/etc/pureftpd.pdb & sudo /etc/init.d/pure-ftpd start (More information on http://www.pureftpd.org/README.Virtual-Users) ************************************************************ how to configure pure-FTPd with virtual users and MySQL(3) ========================================================== 1. create the database mysql -u root -p /* we don't create a new database for it. We use existing 99_database CREATE DATABASE pureFTPdDatabase; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureFTPdDatabase.* TO 'pureFTPdUser'@'localhost' IDENTIFIED BY 'password'; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureFTPdDatabase.* TO 'pureFTPdUser'@'localhost.localdomain' IDENTIFIED BY 'password'; FLUSH PRIVILEGES; USE pureFTPdDatabase; */ 2. create the table USE 99_database; CREATE TABLE ftpUser ( 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; 3. Make sure that you are logged in as root sudo su 4. Configure PureFTPd (Edit /etc/pure-ftpd/db/mysql.conf. It should look like this:) 4.1 cp /etc/pure-ftpd/db/mysql.conf /etc/pure-ftpd/db/mysql.conf_orig 4.2 cat /dev/null > /etc/pure-ftpd/db/mysql.conf 4.3 nano /etc/pure-ftpd/db/mysql.conf MYSQLSocket /var/run/mysqld/mysqld.sock MYSQLServer localhost MYSQLPort 3306 MYSQLUser 99webhosting MYSQLPassword password MYSQLDatabase 99_database #MYSQLCrypt md5, cleartext, crypt() or password() - md5 is VERY RECOMMENDABLE uppon cleartext MYSQLCrypt md5 MYSQLGetPW SELECT Password FROM ftpUser WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MYSQLGetUID SELECT Uid FROM ftpUser WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MYSQLGetGID SELECT Gid FROM ftpUser WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MYSQLGetDir SELECT Dir FROM ftpUser WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpUser WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpUser WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetQTASZ SELECT QuotaSize FROM ftpUser WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetQTAFS SELECT QuotaFiles FROM ftpUser WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") 5. create the file /etc/pure-ftpd/conf/ChrootEveryone which simply contains the string yes: echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone 6. Also create the file /etc/pure-ftpd/conf/CreateHomeDir which again simply contains the string yes: (This will make PureFTPd create a user's home directory when the user logs in if the home directory does not exist yet.) echo "no" > /etc/pure-ftpd/conf/CreateHomeDir 7. Finally create the file /etc/pure-ftpd/conf/DontResolve which again simply contains the string yes: (This will make that PureFTPd doesn't look up host names which can significantly speed up connections and reduce bandwidth usage. It's already done by starting pure-ftpd with -j) echo "yes" > /etc/pure-ftpd/conf/DontResolve 8*. Others: 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 "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 echo “no” > /etc/pure-ftpd/conf/DisplayDotFiles echo “5000 500" > /etc/pure-ftpd/conf/LimitRecursion 9. start PureFTPd sudo tcpserver -DHRl0 0 21 /usr/local/sbin/pure-ftpd -j -A -E -b -F /etc/pure-ftpd/welcome.msg -l mysql:/etc/pure-ftpd/db/mysql.conf & or: sudo /etc/init.d/pure-ftpd-mysql restart 10. Now we create the user exampleuser: mysql -u root -p USE 99_database; INSERT INTO `ftpUser` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`, `ULBandwidth`, `DLBandwidth`, `comment`, `ipaccess`, `QuotaSize`, `QuotaFiles`) VALUES ('username', '1', MD5('password'), '5002', '5002', '/media/newDisk500GB/public', '100', '100', '', '*', '50', '0'); quit; ////////////////////////////////////////////////////////////// trouble-shooting: Unable to start a standalone server: Address already in use ============================================================================== inetd has a lock on port 21 You can confirm this by doing a: sudo fuser -n tcp 21 The command above will spit out a pid if something is using the port named (21) Look up the pid in System Monitor..... probably inetd For a single session you can: sudo kill [pid] Then try running pure-ftpd again....should work If so, set inetd to not start @ boot: sudo mv /etc/inetd.conf /etc/inetd.orig.conf reboot if... /////////////////////////////// How to change welcome message (optional) ======================================== OK.. that is easy. If you want to disable pure-ftpd welcome message at all. you will need to compile it with the flag --no-banner if you want to change the default one to your own welcome msg, add when you start up pire-ftpd -F /pure-ftpd/welcome.msg where /pure-ftpd/welcome.msg is the path/filename to your new welcome.msg //////////////////////// how to change folder owner and permission (optional) ==================================================== 1. display the owner and permission ls -l /media/ drwxrwxr-t 4 root plugdev 4096 2009-11-16 12:14 newDisk500GB 2. change sudo chown -R root:ftpgroup /media/newDisk500GB sudo chmod -R 775 /media/newDisk500GB (or: sudo chmod -R 1775 /media/newDisk500GB) (1 - the user can only delete their own files)