[Guide] Install Pure-FTPd in Ubuntu server

Pure-FTPd is a free (BSD), secure, production-quality and standard-conformant FTP server. It doesn’t provide useless bells and whistles, but focuses on efficiency and ease of use. It provides simple answers to common needs, plus unique useful features for personal users as well as hosting providers.
Official website: https://www.pureftpd.org/project/pure-ftpd

Installation

In this guide, I’ll show you how to install Pure-FTPd in a Ubuntu Server using a MySQL table for the ftp-user-management.

Update the packages and install Pure-FTPd:
# sudo apt-get update
# sudo apt-get install pure-ftpd-mysql

Create group and user to map all virtual ftp accounts:
# groupadd -g 2001 ftpgroup
# useradd -u 2001 -s /bin/false -d /bin/null -c "pureftpd user" -g ftpgroup ftpuser

Configure MySQL [Edit password and localhost.domain]:
# mysql -u root -p

Create the database for Pure-FTPd, create the user, and grant the DB:
CREATE DATABASE pureftpd;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost' IDENTIFIED BY 'writepassword';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost.hostname' IDENTIFIED BY 'writepassword';
FLUSH PRIVILEGES;

Now create the table where you’ll create the FTP accounts:
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)
);

You can now exit from MySQL: quit;

Edit now the file /etc/pure-ftpd/db/mysql.conf
This is an example of the content to edit in the file. You can do other configs:

MYSQLSocket /var/run/mysqld/mysqld.sock
MYSQLUser pureftpd
MYSQLPassword writeyourpassword
MYSQLDatabase pureftpd
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’)
MySQLGetQTAFS SELECT QuotaFiles 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’)
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’)

Now, it’s necessary to create some configs (you can tune up as you want):
# cd /etc/pure-ftpd/conf/
# echo 'yes' > ChrootEveryone
# echo 'yes' > CreateHomeDir
# echo 'yes' > BrokenClientsCompatibility
# echo '50' > MaxClientsNumber
# echo '5' > MaxClientsPerIP
# echo 'no' > AnonymousOnly
# echo 'yes' > NoAnonymous
# echo 'no' > PAMAuthentication
# echo 'no' > UnixAuthentication
# echo 'no' > AnonymousCanCreateDirs
# echo 'no' > AllowUserFXP
# echo 'no' > AllowAnonymousFXP
# echo 'yes' > NoChmod
# echo '80' > MaxDiskUsage

Restart service: # /etc/init.d/pure-ftpd-mysql restart
Probably apache has been installed. You can uninstall it if you don’t need it: # sudo apt-get purgeapache2*

Leave us your feedback !

Add a comment

*Please complete all fields correctly

Related Blogs

Posted by misterioso | January 6, 2018
[Fix] SourceTree: Git over SSH
If you have problems with the connection between SourceTree and your git repo over SSH, this post should be useful for you… A common error is: “FATAL ERROR: Server unexpectedly...
Posted by misterioso | January 6, 2018
[Guide] Install NGINX in Ubuntu server
NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple...
Posted by misterioso | January 5, 2018
[Guide] Install GitLab in Ubuntu server
GitLab is a web-based Git repository manager with some useful tools like board, wiki, issue tracking,… The community edition comes with an open source license and this platform is developed by GitLab Inc....