VMware Images:
|
Virtual Hosting With PureFTPd And MySQL (Incl. Quota And Bandwidth Management) On Debian Lenny - Page 2
5 Configure PureFTPdEdit /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
Make sure that you replace the string ftpdpass with the real password for the MySQL user pureftpd in the line MYSQLPassword! Please note that we use md5 as MYSQLCrypt method, which means we will store the users' passwords as an MD5 string in the database which is far more secure than using plain text passwords! 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. Now we must configure PureFTPd as a standalone daemon (it is currently controlled by inetd). To do this, we open /etc/default/pure-ftpd-common and change the value of the parameter STANDALONE_OR_INETD to standalone: vi /etc/default/pure-ftpd-common
Next, we modify /etc/inetd.conf and comment out the ftp line: vi /etc/inetd.conf
Afterwards, we restart Inetd and PureFTPd: /etc/init.d/openbsd-inetd restart
6 Populate The Database And TestTo populate the database you can use the MySQL shell: mysql -u root -p USE pureftpd; Now we create the user exampleuser with the status 1 (which means his ftp account is active), the password secret (which will be stored encrypted using MySQL's MD5 function), the UID and GID 2001 (use the userid and groupid of the user/group you created at the end of step two!), the home directory /home/www.example.com, an upload and download bandwidth of 100 KB/sec. (kilobytes per second), and a quota of 50 MB: INSERT INTO `ftpd` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`, `ULBandwidth`, `DLBandwidth`, `comment`, `ipaccess`, `QuotaSize`, `QuotaFiles`) VALUES ('exampleuser', '1', MD5('secret'), '2001', '2001', '/home/www.example.com', '100', '100', '', '*', '50', '0'); quit; Now open your FTP client program on your work station (something like WS_FTP or SmartFTP if you are on a Windows system or gFTP on a Linux desktop) and try to connect. As hostname you use server1.example.com (or the IP address of the system), the username is exampleuser, and the password is secret. If you are able to connect - congratulations! If not, something went wrong. Now, if you run ls -l /home you should see that the directory /home/www.example.com (exampleuser's home directory) has been automatically created, and it is owned by ftpuser and ftpgroup (the user/group we created at the end of step three): server1:~# ls -l /home
7 Database AdministrationFor most people it is easier if they have a graphical front-end to MySQL; therefore you can also use phpMyAdmin (in this example under http://server1.example.com/phpmyadmin/) 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:
8 Anonymous FTPIf 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 Then create the file /etc/pure-ftpd/conf/NoAnonymous which contains the string no: echo "no" > /etc/pure-ftpd/conf/NoAnonymous 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 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).
9 Links
|





Recent comments
16 hours 39 min ago
18 hours 14 min ago
22 hours 35 min ago
1 day 2 hours ago
1 day 14 hours ago
1 day 20 hours ago
1 day 22 hours ago
2 days 20 min ago
2 days 36 min ago
2 days 1 hour ago