Table of Contents#
- Prerequisites
- Install ProFTPD
- Configure ProFTPD for Anonymous Access
- Create the Anonymous Directory
- Set Up Appropriate Permissions
- Restart and Enable ProFTPD
- Test the Anonymous FTP Access
- Security Considerations
- Conclusion
- References
Prerequisites#
- A RHEL/CentOS 7 system with root or sudo privileges.
- Basic knowledge of the Linux command line.
- Internet connectivity to install packages.
Install ProFTPD#
First, you need to install the ProFTPD server on your system. Follow these steps:
- Update the system's package repositories:
sudo yum update -y- Enable the EPEL repository (ProFTPD is not included in the default RHEL/CentOS 7 repositories):
sudo yum install epel-release -y- Install ProFTPD:
sudo yum install proftpd -yConfigure ProFTPD for Anonymous Access#
Next, you'll need to modify the ProFTPD configuration file to enable anonymous access:
- Open the ProFTPD configuration file using your preferred text editor. The default configuration file is
/etc/proftpd.conf:
sudo vi /etc/proftpd.conf- Find and add or modify the following lines in the configuration file. If these lines don't exist, you can add them to the end of the file:
# Enable anonymous access
<Anonymous ~ftp>
User ftp
Group ftp
RequireValidShell off
# Limit access to read - only
<Limit WRITE>
DenyAll
</Limit>
</Anonymous>In this configuration:
<Anonymous ~ftp>defines an anonymous login section. The~ftprefers to the home directory of theftpuser.User ftpandGroup ftpspecify that anonymous users will operate under theftpuser and group.- The
<Limit WRITE>block restricts anonymous users from writing to the server.
Create the Anonymous Directory#
Anonymous users will access files in a specific directory. You need to create this directory:
- Create the directory:
sudo mkdir -p /var/ftp/pub- Place some sample files in the directory for testing purposes:
sudo touch /var/ftp/pub/testfile.txtSet Up Appropriate Permissions#
To ensure that anonymous users can access the files, you need to set the correct permissions:
sudo chown -R ftp:ftp /var/ftp
sudo chmod -R 555 /var/ftpThe chown command changes the owner and group of the /var/ftp directory to the ftp user and group. The chmod command sets the directory and its contents to be readable and executable by all users.
Restart and Enable ProFTPD#
After making the configuration changes, you need to restart and enable ProFTPD:
sudo systemctl restart proftpd
sudo systemctl enable proftpdThe restart command restarts the ProFTPD service, and the enable command ensures that the service starts automatically at boot time.
Test the Anonymous FTP Access#
You can test the anonymous FTP access using an FTP client. On the command line, you can use the ftp utility:
ftp <your_server_ip>When prompted for a username, enter anonymous. For the password, you can enter any valid email address or just press Enter. If the connection is successful, you should be able to list the files in the /pub directory:
ftp> lsSecurity Considerations#
- Read - Only Access: As shown in the configuration, it's recommended to limit anonymous users to read - only access to prevent unauthorized modifications.
- File and Directory Permissions: Ensure that only necessary files are accessible to anonymous users and that all other sensitive directories are properly protected.
- Firewall Configuration: Configure your firewall to allow only FTP traffic on the appropriate ports (usually port 21). You can use
firewalldto manage your firewall rules:
sudo firewall-cmd --permanent --add-service=ftp
sudo firewall-cmd --reloadConclusion#
Enabling an anonymous account for a ProFTPD server in RHEL/CentOS 7 is a straightforward process that involves installing the server, configuring it for anonymous access, creating an appropriate directory, and setting up the necessary permissions. By following the steps outlined in this blog post, you can provide a simple way for users to download files from your server without the need for authentication.
References#
- ProFTPD official documentation: http://www.proftpd.org/docs/
- RHEL/CentOS 7 official documentation: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/