We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Configure Vsftpd FTP Server on Rocky Linux 8|AlmaLinux 8

Learn how to – Configure Vsftpd FTP Server on Rocky Linux 8|AlmaLinux 8.

FTP is an acronym for File Transfer Protocol. This application layer protocol is essential where the seamless transfer or data exchange between devices over the internet is required. File upload and download in an FTP application is made easy using TCP(Transmission Control Protocol)

VSFTPD, an acronym for Very Secure FTP Daemon secures data transfer on FTP by creating secure tunnels to encrypt the data flow. With Vsftpd, data transfer security is guaranteed since an end to end encryption is enforced.

The amazing features related to Vsftpd include:

  • Stability – This is a very consistent and reliable FTP server.
  • IP independent – with support for both IPv4 and IPv6.
  • Supports Standalone or inetd operation
  • It handles Bandwidth throttling
  • Powerful per-user configurability
  • Secure – Supports encryption through TLS/SSL integration
  • Fast and reliable – there is minimal interference since files are download via a private tunnel
  • Virtual users – this is and added security feature because whenever a real user account is compromised, user can only use FTP Server but can not login to system to use other services like SSH.

By following the below steps, you should be able to configure the Vsftpd FTP Server on Rocky Linux 8 / AlmaLinux 8.

1. Install vsftpd on Rocky Linux 8/ AlmaLinux 8

The first thing we need to do is to install the Very Secure FTP Daemon which is available in the default Rocky Linux 8/ AlmaLinux 8 repositories.

sudo yum update
sudo yum install vsftpd

Dependency tree:

Dependencies resolved.
================================================================================
 Package         Architecture    Version               Repository          Size
================================================================================
Installing:
 vsftpd          x86_64          3.0.3-34.el8          appstream          180 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 180 k
Installed size: 347 k
Is this ok [y/N]: y

Once the installation is successful, verify the installed version of Vsftpd as below.

$ sudo rpm -qi vsftpd
Name        : vsftpd
Version     : 3.0.3
Release     : 34.el8
Architecture: x86_64
Install Date: Sat 12 Feb 2022 02:30:16 AM EST
Group       : System Environment/Daemons
Size        : 355732
License     : GPLv2 with exceptions
Signature   : RSA/SHA256, Tue 09 Nov 2021 10:07:58 AM EST, Key ID 15af5dac6d745a60
Source RPM  : vsftpd-3.0.3-34.el8.src.rpm
Build Date  : Tue 09 Nov 2021 09:27:17 AM EST
Build Host  : ord1-prod-x86build004.svc.aws.rockylinux.org
Relocations : (not relocatable)
Packager    : infrastructure@rockylinux.org
Vendor      : Rocky
URL         : https://security.appspot.com/vsftpd.html
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.

Start and enable the Very Secure FTP Daemon to run automatically on system boot.

sudo systemctl enable vsftpd --now 

Check the status of the service.

$ systemctl status vsftpd
 vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2022-02-12 02:30:39 EST; 6s ago
  Process: 32110 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
 Main PID: 32111 (vsftpd)
    Tasks: 1 (limit: 36438)
   Memory: 580.0K
   CGroup: /system.slice/vsftpd.service
           └─32111 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

Feb 12 02:30:38 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...
Feb 12 02:30:39 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.

2. Create the FTP User and User Directory

We need to create and grant dedicated user access to the FTP server. We will create the user as below.

sudo adduser vsftpduser
sudo passwd vsftpduser

With the user and password created as above, proceed and create the FTP directories with the necessary permissions.

sudo mkdir -p /home/vsftpduser/ftp_folder
sudo chmod -R 750 /home/vsftpduser/ftp_folder
sudo chown vsftpduser: /home/vsftpduser/ftp_folder

To grant the user access to the Vsftpd server, add them to the /etc/vsftpd/user_list file.

sudo bash -c 'echo vsftpduser >> /etc/vsftpd/user_list'

3. Configure vsftpd on Rocky Linux 8/ AlmaLinux 8.

We need to make some adjustments to the Vsftpd config file accessed as below.

sudo vi /etc/vsftpd/vsftpd.conf

With the file opened, make the below adjustments:

  • Allow remote access to local users then block anonymous users.
anonymous_enable = NO
local_enable = YES
  • Grant user permission to run ant FTP commands.
write_enable = YES
  • Restrict user access to their home directory only and grant the write permissions.
chroot_local_user=YES
allow_writeable_chroot=YES
  • Set custom ports to enable passive FTP connections.
pasv_min_port=30000
pasv_max_port=31000
  • Allow dedicated Vsftpd users in the user_list file to access the FTP server.
userlist_file=/etc/vsftpd/user_list
userlist_enable=YES
userlist_deny=NO

With the above changes made, restart the server.

sudo systemctl restart vsftpd

4. Open FTP Ports on Firewalld

Based on the above configuration, we have set the passive communication port range between 30000-31000. We now need to allow these ports through the firewall. Also, we need to allow port range 20-21 for FTP data and traffic.

sudo firewall-cmd --permanent --add-port=20-21/tcp
sudo firewall-cmd --permanent --add-port=30000-31000/tcp

Apply the changes to the firewall daemon.

sudo firewall-cmd --reload

Now test the FTP connection using the below command:

ftp serverIP

Sample Output:

5. Vsftpd SSL/TLS Configuration on Rocky Linux 8/ AlmaLinux 8

For security and encryption reasons on the FTP server, we will generate SSL certificates on this system.

In this guide, we use self-signed certificates generated using OpenSSL as below.

First, ensure OpenSSL is installed

sudo yum install openssl

Then generated the self-signed certificates.

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/vsftpd.pem -out /etc/vsftpd/vsftpd.pem

On the output, provide the required country name, state/province details e.t.c

Now get back to the Vsftpd config file and add the generated certificates path.

$ sudo vi /etc/vsftpd/vsftpd.conf 
#Add these lines###
rsa_cert_file=/etc/vsftpd/vsftpd.pem
rsa_private_key_file=/etc/vsftpd.pem

#Enable SSL##
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO

Save the changes and restart Vsftpd.

sudo systemctl restart vsftpd

6. Test FTP using FTP Client(Filezilla)

We now want to test the FTP server using the Filezilla FTP client that can be installed on both Windows and Linux systems. For Windows, download and install the Filezilla.exe file, on Linux proceed as below.

# [On Debian, Ubuntu & Mint]
sudo apt install filezilla

#[On RHEL/CentOS/Fedora & Rocky Linux/AlmaLinux]
sudo yum install filezilla

#[On Arch Linux]
sudo pacman -S filezilla

#[On OpenSUSE]  
sudo zypper in filezilla

Once installed, launch Filezilla and navigate to File->Site Manager.

Now enter the FTP server details as shown

With the correct details entered, click connect. You will be granted the earlier created certificate, click Ok to proceed.

Once the connection has been established, you will be granted a window divided into two parts with one part showing the local server and the other showing the Vsftpd server with the created directory(ftp_folder).

Now using the vsftpduser created earlier, we can upload files to the server.

The uploaded file will be available on the FTP server as below.

You can as well download files as below.

The downloaded file appears on your local machine as shown.

Closing Thoughts.

We triumphantly configured the Vsftpd FTP Server on Rocky Linux 8 / AlmaLinux 8. You can now share files securely over the private tunnel. I hope this was significant to you.

Find more on this page:

Cart

Your Cart is Empty

Back To Shop