How to Setup Secure FTP Server with VSFTPD on Ubuntu 24.04
Learn how to setup secure ftp server with vsftpd on ubuntu 24.04 with TLS/SSL encryption, chroot user isolation, passive port ranges, and UFW rules.

5 min read
Learn how to setup secure ftp server with vsftpd on ubuntu 24.04 with TLS/SSL encryption, chroot user isolation, passive port ranges, and UFW rules.
- Prerequisites and Supported Releases
- Step 1: Installing VSFTPD on Ubuntu 24.04
- Step 2: Creating a Dedicated FTP User and Directory Hierarchy
File Transfer Protocol (FTP) has been a cornerstone of networked file sharing and website content delivery for decades.
However, traditional plain FTP is inherently insecure because it transmits usernames, passwords, and file contents across networks in unencrypted cleartext.
To protect sensitive data from eavesdropping and man-in-the-middle attacks, administrators implement FTPS (FTP over Transport Layer Security).
VSFTPD (Very Secure FTP Daemon) is the industry-standard, lightweight, highly secure FTP server for Linux systems, renowned for its strong security model, speed, and resilience against buffer overflows.
In this guide, we walk through how to setup secure ftp server with vsftpd on ubuntu, enforce SSL/TLS encryption, jail users to their home directories, and configure firewall rules.
Complete step-by-step administrator tutorial on building a secure FTPS (FTP over SSL/TLS) server using VSFTPD (Very Secure FTP Daemon) on Ubuntu 24.04 LTS (Noble Numbat) and 22.04 LTS. Covers isolating user accounts in chroot jails, generating self-signed TLS certificates, configuring passive port ranges, and testing encrypted transfers with FileZilla.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A server running Ubuntu 24.04 LTS or Ubuntu 22.04 LTS.
- A non-root administrative user with
sudoprivileges. - UFW firewall installed.
- An FTP client that supports FTPS (such as FileZilla or WinSCP).
Step 1: Installing VSFTPD on Ubuntu 24.04
VSFTPD is available in Ubuntu's official repositories.
First, update your APT package cache, then install the vsftpd package:
Verify that the VSFTPD systemd service is active and running:
# Update package lists:
sudo apt update
# Install VSFTPD:
sudo apt install -y vsftpd
# Verify service status and enable on boot:
sudo systemctl enable --now vsftpd
sudo systemctl status vsftpd
# Expected output: Active: active (running)
Step 2: Creating a Dedicated FTP User and Directory Hierarchy
For security reasons, avoid logging into FTP using your administrative user account.
Create a dedicated unprivileged user named ftpuser with disabled shell login:
Set up a dedicated FTP upload directory and enforce chroot jail directory permissions:
# Create dedicated ftpuser with no shell access:
sudo adduser --disabled-login --gecos "" ftpuser
sudo passwd ftpuser
# Create home and upload directories:
sudo mkdir -p /home/ftpuser/ftp/files
# Set ownership of ftp root to nobody:nogroup (read-only for chroot):
sudo chown nobody:nogroup /home/ftpuser/ftp
sudo chmod a-w /home/ftpuser/ftp
# Set upload directory ownership to ftpuser:
sudo chown ftpuser:ftpuser /home/ftpuser/ftp/files
sudo chmod 755 /home/ftpuser/ftp/files
Step 3: Generating an SSL/TLS Certificate for Encrypted FTPS
To enforce modern TLS encryption, generate a private cryptographic key and SSL certificate using OpenSSL.
Store the certificate and private key in /etc/ssl/private/ with restricted access permissions:
Run the following command to generate a 2048-bit RSA certificate valid for 365 days:
# Generate self-signed SSL certificate for VSFTPD:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/private/vsftpd.pem \
-out /etc/ssl/private/vsftpd.pem \
-subj "/C=US/ST=State/L=City/O=WebsiteVidya/CN=ftp.example.com"
# Restrict permissions to root:
sudo chmod 600 /etc/ssl/private/vsftpd.pem
Step 4: Hardening the VSFTPD Configuration (/etc/vsftpd.conf)
Back up the original configuration file, then author a hardened configuration in /etc/vsftpd.conf.
This configuration restricts anonymous access, enables local write permissions, confines users to chroot jails, mandates TLS encryption, and defines a passive port range:
Apply the following settings to /etc/vsftpd.conf:
# Back up original config:
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
# Write hardened configuration:
cat << 'EOF' | sudo tee /etc/vsftpd.conf
# General Settings
listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
# Chroot Jail Settings
chroot_local_user=YES
chroot_list_enable=NO
user_sub_token=$USER
local_root=/home/$USER/ftp
allow_writeable_chroot=YES
# Passive Mode Ports
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40100
# SSL/TLS Encryption Directives
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1_2=YES
ssl_tlsv1_3=YES
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
EOF
# Restart VSFTPD to apply changes:
sudo systemctl restart vsftpd
Step 5: Opening Firewall Ports in UFW
FTP utilizes port 21 for command control and port 20 for active data transfers.
In passive mode, the client initiates connections to a designated high-numbered port range (40000 to 40100 defined in our configuration):
Open command ports and the passive port range in UFW:
# Allow standard FTP command ports:
sudo ufw allow 20/tcp comment 'FTP Data'
sudo ufw allow 21/tcp comment 'FTP Control'
# Allow passive port range:
sudo ufw allow 40000:40100/tcp comment 'VSFTPD Passive Ports'
# Verify active UFW rules:
sudo ufw status
Step 6: Testing Encrypted FTPS Connection with FileZilla
Connect to your FTPS server using a client like FileZilla or WinSCP to verify TLS handshake and file transfers:
Configure your connection profile using these parameters:
| FileZilla Setting | Value to Configure | Purpose |
|---|---|---|
| Host | YOUR_SERVER_IP or domain.com | Target server endpoint |
| Protocol | FTP - File Transfer Protocol | Standard protocol family |
| Encryption | Require explicit FTP over TLS | Mandates encrypted command and data channels |
| Logon Type | Normal | Authenticates with username and password |
| User / Password | ftpuser / password set in Step 2 | Unprivileged jailed account credentials |
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
500 OOPS: vsftpd: refusing to run with writable root inside chroot()
Cause: The user's home root directory has write permissions enabled while chroot_local_user=YES is active.
Resolution: Ensure allow_writeable_chroot=YES is included in /etc/vsftpd.conf, or remove write permissions from /home/ftpuser/ftp using chmod a-w.
sudo chmod a-w /home/ftpuser/ftp && sudo systemctl restart vsftpd
Directory listing hanging or timing out in FileZilla
Cause: Passive port range (40000-40100) is blocked by UFW or an external cloud security group.
Resolution: Open TCP ports 40000 through 40100 in both UFW and your cloud provider network firewall.
sudo ufw allow 40000:40100/tcp
530 Non-anonymous sessions must use encryption
Cause: Client attempted an unencrypted plain FTP connection while force_local_logins_ssl=YES is enforced.
Resolution: Configure your FTP client to connect using 'Require explicit FTP over TLS' (FTPS).
cat /etc/vsftpd.conf | grep force_local_logins_ssl
Security Best Practices and Hardening
Never allow anonymous uploads in production; ensure anonymous_enable=NO remains set in /etc/vsftpd.conf.
Confine all FTP users to their home directory chroot jail to prevent unauthorized traversing of root filesystems.
Consider using SFTP (SSH File Transfer Protocol) over port 22 as a firewall-friendly, modern alternative to FTPS if passive port configuration is undesirable.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- How to Set Up a Firewall with UFW on Ubuntu 24.04 — Configure UFW rules and manage passive port ranges for FTP services.
- How to Set a Static IP Address on Ubuntu Server and Desktop — Configure predictable network addressing for dedicated file servers.
- How to Create a Sudo User on Ubuntu — Manage system user accounts, privileges, and group assignments.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
rsa_cert_file and rsa_private_key_file in /etc/vsftpd.conf to your Certbot certificates located at /etc/letsencrypt/live/domain.com/fullchain.pem and privkey.pem./etc/ftpusers, which contains a blacklist of user accounts forbidden from logging into VSFTPD.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!