How to Setup PureFTPd on CentOS 7.0

Posted on : February 12, 2015 , Last Updated on : December 4, 2016 By
| 2 Replies More

Hi all, today in this tutorial, we'll be compiling and installing PureFTPd from source on CentOS 7. Pure-ftpd is a lightweight and stable FTP daemon which supports various authentication backends like Linux system users, puredb, MySQL and PostgeSQL.

1. Installing Pureftpd

Install the CentOS development toolchain.

# yum -y groupinstall 'Development Tools'

Install the MariaDB development files.

# yum -y install mariadb-devel

Download the pure-ftpd source files and unpack the archive.

# cd /usr/local/src
# wget
# tar xvjpf pure-ftpd-1*.tar.bz2
# cd pure-ftpd-1*

downloading latest pureftpd

Run the configure command to prepare the build. To get a overview of all compile ptions, run ./configure --help.

# ./configure --prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin \
--libexecdir=/usr/libexec --datadir=/usr/share --sysconfdir=/etc \
 --sharedstatedir=/usr/com --localstatedir=/var --libdir=/usr/lib64 \
 --includedir=/usr/include --infodir=/usr/share/info --mandir=/usr/share/man \
 --with-mysql --with-virtualchroot --with-everything

configure pureftpd package

and compile the pure-ftpd binary:

# make
# make install

2. Creating config files and startscripts

First we create the start script. For this build we will use the start script from CentOS 6.5 which still works fine on CentOS 7.

# nano /etc/init.d/pure-ftpd
 # Startup script for the pure-ftpd FTP Server $Revision: 1.1 $
 # chkconfig: - 85 15
 # description: Pure-FTPd is an FTP server daemon based upon Troll-FTPd
 # processname: pure-ftpd
 # pidfile: /var/run/
 # config: /etc/pure-ftpd/pure-ftpd.conf
# Source function library.
 . /etc/init.d/functions
# Source networking configuration.
 . /etc/sysconfig/network
# Check that networking is configured.
 # [ ${NETWORKING} = "no" ] && exit 0
# Path to the pure-ftp binaries.
 start() {
 echo -n $"Starting $prog: "
 daemon "$pure_launch_script $pure_config --daemonize > /dev/null"
 [ $RETVAL = 0 ] && touch /var/lock/subsys/pure-ftpd
stop() {
 echo -n $"Stopping $prog: "
 killproc pure-ftpd
 [ $RETVAL = 0 ] && rm -f /var/lock/subsys/pure-ftpd
# See how we were called.
 case "$1" in
 echo -n $"Reloading $prog: "
 killproc pure-ftpd -HUP
 if [ -f /var/lock/subsys/pure-ftpd ] ; then
 # avoid race
 sleep 3
 status pure-ftpd
 if [ -f $pureftpwho ] && [ $RETVAL -eq 0 ] ; then
 echo $"Usage: pure-ftpd {start|stop|restart|reload|condrestart|status}"
 exit $RETVAL

 configuring startup script

3. Configuring File Permissions

Now, we'll need to provide the required file permissions by the commands below which includes configuring post installation stuffs.

# chmod +x /etc/init.d/pure-ftpd
# mkdir /etc/pure-ftpd/
# cp configuration-file/pure-ftpd.conf /etc/pure-ftpd/pure-ftpd.conf
# cp configuration-file/ /usr/sbin/
# chmod 744 /etc/pure-ftpd/pure-ftpd.conf
# chmod 755 /usr/sbin/

Then create the system startup links and start PureFTPd:

# chkconfig --levels 235 pure-ftpd on
# systemctl start pure-ftpd.service

setting file permissions

4. Configuring TLS with OpenSSL

Now we configure PureFTPd to allow FTP and TLS sessions. FTP without TLS is a very insecure protocol because all passwords and all data are transferred in clear text. By using TLS, the whole communication can be encrypted, thus making FTP much more secure.
OpenSSL is needed by TLS; to install OpenSSL, we simply run:

# yum -y install openssl

Open /etc/pure-ftpd/pure-ftpd.conf...

# nano /etc/pure-ftpd/pure-ftpd.conf

If you want to allow FTP and TLS sessions, set TLS to 1:
# This option can accept three values :
# 0 : disable SSL/TLS encryption layer (default).
# 1 : accept both traditional and encrypted sessions.
# 2 : refuse connections that don't use SSL/TLS security mechanisms,
# including anonymous sessions.
# Do _not_ uncomment this blindly. Be sure that :
# 1) Your server has been compiled with SSL/TLS support (--with-tls),
# 2) A valid certificate is in place,
# 3) Only compatible clients will log in.

In order to use TLS, we must create an SSL certificate. I create it in /etc/ssl/private/, therefore I create that directory first:
mkdir -p /etc/ssl/private/

Afterwards, we can generate the SSL certificate as follows:

# openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem

Change the permissions of the SSL certificate:

# chmod 600 /etc/ssl/private/pure-ftpd.pem

Finally restart PureFTPd:

# systemctl stop pure-ftpd.service
# systemctl start pure-ftpd.service


Hurray, we have successfully installed and configured pureftpd. Now we can enjoy FTP data transfer with TLS security. Please note, while connecting the FTP server we should configure our FTP client to use TLS if you installed and configured SSL certificates correctly. And by default, pureftpd will open port 21 to communicate with the client. If you have any problem, queries or questions please comment below without hesitation so that we can update and improve our blogs and contents more.

Filed Under : LINUX HOWTO

Tagged With :

Free Linux Ebook to Download

Comments (2)

Trackback URL | Comments RSS Feed

  1. Nick H says:

    I'm using CentOS v7.1 and have pure-ftpd (from the EPEL repository) installed. The location of the private key and certificate with this configuration is "/etc/pki/pure-ftpd/pure-ftpd.pem". So, to generate a self signed SSL certificate the command would be "openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/pki/pure-ftpd/pure-ftpd.pem -out /etc/pki/pure-ftpd/pure-ftpd.pem". You should probably also run "chmod 600 /etc/pki/pure-ftpd/pure-ftpd.pem" just to be safe.

Leave a Reply

All comments are subject to moderation.