Install and Configure Pure FTPd with Mysql on Centos 8

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Pure FTPd is an open source and secure FTP server. It is one of the widely used FTP server for its security, ease of use and ability to connect to a database.

In this article we will install and configure FTPd on CentOS 8.

Get EPEL repository for CentOS 8:

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Install FTPd using the following command:

dnf install pure-ftpd

Now create a user and group for FTPd server.

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

make the following changes:

   ChrootEveryone              yes
   MaxClientsNumber            50
   MaxClientsPerIP             2
   VerboseLog                  yes
   AnonymousOnly               no
   NoAnonymous                 yes
   MaxIdleTime                 15
   MySQLConfigFile             /etc/pure-ftpd/pureftpd-mysql.conf
   PAMAuthentication    	no
   UnixAuthentication     	no

Now we will edit pure-ftpd mysql configuration file.

nano /etc/pure-ftpd/pureftpd-mysql.conf

Uncomment the following lines:

# Optional : MySQL server name or IP. Don't define this for unix sockets.

 MYSQLServer     127.0.0.1


# Optional : MySQL port. Don't define this if a local unix socket is used.

 MYSQLPort       3306

update the following values:

MYSQLUser       pureftpd
MYSQLPassword   password
MYSQLDatabase   pureftpd
MYSQLCrypt      md5

Allow ftp service through firewall.

firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload

Enable and start pure FTPd service.

systemctl enable pure-ftpd.service
systemctl start pure-ftpd.service
systemctl status pure-ftpd.service

After installation, we will configure it for mariaDB.

Install MariaDB using the following command:

dnf install @mariadb

Start and Enable MariaDB Service.

systemctl enable --now mariadb
systemctl status mariadb

We will now set root password for MariaDB and other security checks because there is no root password set now, use the following command:

mysql_secure_installation

A prompt will ask you to set root password for the MariaDB. Once you do that, the script will ask you to remove the anonymous user, restrict root user access and remove the test database. You should answer “Y” (yes) to all options.

We will now login into mariaDB and create database, table and user and store information accordingly.

mysql -u root -p

Now enter following commands:

CREATE DATABASE pureftpd;
GRANT ALL ON pureftpd.* to 'pureftpd'@'localhost' IDENTIFIED BY '_password_';
FLUSH PRIVILEGES;
use pureftpd;
CREATE TABLE `users` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `User` varchar(32) NOT NULL DEFAULT '',
  `Password` varchar(64) NOT NULL DEFAULT '',
  `Uid` int(3) NOT NULL DEFAULT '500',
  `Gid` int(3) NOT NULL DEFAULT '500',
  `Dir` varchar(255) NOT NULL DEFAULT '',
  `QuotaSize` int(4) NOT NULL DEFAULT '50',
  `Status` enum('0','1') NOT NULL DEFAULT '1',
  `ULBandwidth` int(2) NOT NULL DEFAULT '100',
  `DLBandwidth` int(2) NOT NULL DEFAULT '100',
  `Date` date NOT NULL DEFAULT '0000-00-00',
  `LastModif` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `User` (`User`),
  KEY `Uid` (`Uid`),
  KEY `Gid` (`Gid`),
  KEY `Dir` (`Dir`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

quit;

We have completed pure-ftpd setup, Now we need to test our setup by creating our first ftp account. To test our setup, first we need to create an user in linux system. After that we will use that users UID and GID to create our virtual ftp accounts.

useradd ftp1
passwd ftp1

Now execute the following command to get UID and GID of this account.

cat /etc/passwd | grep ftp1

As per output of the above command UID and GID of this user is 1000.

Now, Login into mariaDB and create your account.

mysql -u root -p

Run the following commands:

use pureftpd;
INSERT INTO `users` (`User`, `Password`, `Uid`, `Gid`, `Dir`, `QuotaSize`,
`Status`, `ULBandwidth`, `DLBandwidth`, `Date`, `LastModif`)
VALUES ('ftpuser1', md5('_password_'), '1000', '1000', '/home/ftp1',
'20', 2, '10', '10', now(), '');
quit

Now you can login into ftp account.

Now you can create files and directories using FTP. We will create a directory named test using pure FTPd.

Now you can use Pure FTPd as per your need.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Mel
Melhttps://unixcop.com
Unix/Linux Guru and FOSS supporter

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook