How to Install and Configure Pure-FTPd on CentOS 7

centos 7 pure-ftpdinstall pure-ftpdconfigure ftp serverfirewall port configurationpure-pw user management
Published·Modified·

Pure-FTPd is a free FTP server software focused on program robustness and software security (based on the BSD License). Currently, common one-click installation packages like Oneinstack, lnmp.org, and Baota have integrated Pure-FTPd, demonstrating its popularity as an FTP service software.

Sometimes, we do not need an overly integrated environment and simply want to use FTP services. You can try configuring Pure-FTPd manually. Here is a guide on how to install and configure Pure-FTPd on CentOS 7.

Install Pure-FTPd

# Install EPEL repository
yum -y install epel-release
# Install pure-ftpd
yum -y install pure-ftpd

Configure Pure-FTPd

The default configuration file for Pure-FTPd is located at /etc/pure-ftpd/pure-ftpd.conf. Common configurations include:

# Specify path, PureDB user database file
PureDB /etc/pure-ftpd/pureftpd.pdb
# Enable verbose logging
VerboseLog yes
# Reject anonymous login
NoAnonymous yes
# Use passive mode and set port range
PassivePortRange             30000 50000

Create System Users, FTP Users, and Configure Directory Permissions

The purpose of creating system users is to allow FTP directories to inherit the permissions of that user. The commands below add a www user and a www user group. Please create users and groups according to your actual situation.

# Create www user group
groupadd www
# Create a www user
useradd -g www -s /sbin/nologin -d /dev/null www

Next, create FTP virtual users, which are the FTP accounts commonly used:

# Create a new FTP directory
mkdir -p /data/wwwroot/ftp
# Set directory permissions
chown -R www:www /data/wwwroot/ftp
# Create an FTP user named xiaoz
pure-pw useradd xiaoz -u www -d /data/wwwroot/ftp -m

Explanation of the command pure-pw useradd xiaoz -u www -d /data/wwwroot/ftp -m:

  • pure-pw useradd xiaoz: Add an FTP user named xiaoz
  • -u www: Specify the system user as www
  • -d /data/wwwroot/ftp: Specify the FTP path
  • -m: Write user information to the pureftpd.pdb database

Allow Ports

FTP uses port 21 by default. Additionally, we configured passive ports (30000-50000). Therefore, these ports need to be allowed in the firewall or security group. Below is the method to allow ports using firewalld. If you are using iptables, please refer to: iptables Firewall, Common Rules Summary.

# Allow port 21
firewall-cmd --zone=public --add-port=21/tcp --permanent
# Allow port range 30000-50000
firewall-cmd --zone=public --add-port=30000-50000/tcp --permanent
# Reload firewalld
firewall-cmd --reload

Start Pure-FTPd

To start Pure-FTPd, simply execute the systemctl start pure-ftpd command. Some common operation commands are listed below.

# Start pure-ftpd
systemctl start pure-ftpd
# Enable boot startup
systemctl enable pure-ftpd
# Stop pure-ftpd
systemctl stop pure-ftpd
# Disable boot startup
systemctl disable pure-ftpd

If you need to get the usage method of pure-ftpd, you can input pure-pw -h to view the help.

Verification

Input the command netstat -apn|grep 'pure-ftpd' to check if Pure-FTPd is listening normally. If listening is successful, you can use an FTP client (such as FileZilla) to connect and ensure that uploading and downloading work correctly.

Others

ImgURL Pro, a professional image hosting program developed by xiaoz, supports FTP image uploading. If needed, you can visit: https://blog.xiaoz.org/archives/13225 to check. Currently, there is a 40% discount promotion.

This article partially references: CentOS7 YUM Install Pure-ftpd