Log inSign up

Encrypted FTP uploads with vsftpd and explicit TLS

Install vsftpd, point rsa_cert_file and rsa_private_key_file at a Let's Encrypt certificate, set ssl_enable=YES with force_local_logins_ssl=YES and force_local_data_ssl=YES, and fix the passive range with pasv_min_port=40000 and pasv_max_port=40100. Open port 21 plus that range in UFW or firewalld, restart the service and connect with an FTP client set to "explicit FTP over TLS". If the people uploading can use SFTP instead, that needs no extra daemon at all.

Topic: Web servers and proxies · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

Should you use FTPS or SFTP?

Choose SFTP whenever the client software allows it, and FTPS only when something insists on FTP. SFTP runs inside SSH, which is already installed and listening on your server: one port, keys or passwords you already manage, and no separate certificate. Most graphical clients, backup tools and IDEs speak it. The SFTP guide shows how to give a user upload access jailed to one folder with only a few lines in sshd_config.

FTPS still has a place. Older website builders, scanners, cameras, accounting packages and some partner integrations only offer FTP, and plain FTP sends passwords in clear text. Explicit FTPS (sometimes written FTPES) starts on port 21 like normal FTP, then upgrades the connection with AUTH TLS before the login, so credentials and files are encrypted. The cost is extra moving parts: a certificate, a second daemon and a block of passive data ports in the firewall.

How do you install vsftpd?

vsftpd is in the base repositories of every system this guide covers:

# Ubuntu and Debian
sudo apt update
sudo apt install -y vsftpd
# config file: /etc/vsftpd.conf

# Rocky Linux 9 and AlmaLinux 9
sudo dnf install -y vsftpd
# config file: /etc/vsftpd/vsftpd.conf

sudo systemctl enable --now vsftpd
dpkg -l vsftpd && systemctl is-active vsftpd     # Ubuntu, Debian
rpm -q vsftpd && systemctl is-active vsftpd       # Rocky, Alma

Both lines print the installed package version (3.0.x on current releases) followed by active. Keep a copy of the stock config for reference before editing: sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig (adjust the path on Rocky and Alma).

How do you get a certificate for the FTP host name?

Use a real certificate so clients can verify the server instead of clicking through warnings. Create a DNS record such as ftp.example.net pointing at 198.51.100.24, then request a certificate. If nothing listens on port 80, Certbot's standalone mode works; if Nginx or Apache already run, use their plugin instead:

# Ubuntu and Debian
sudo apt install -y certbot
# Rocky and Alma
sudo dnf install -y epel-release && sudo dnf install -y certbot

sudo certbot certonly --standalone -d ftp.example.net --deploy-hook "systemctl restart vsftpd"
# or, with Nginx running:
# sudo certbot certonly --nginx -d ftp.example.net --deploy-hook "systemctl restart vsftpd"

The deploy hook restarts vsftpd after each renewal so it loads the new files. Details on renewal and DNS validation are in the Certbot guide.

What goes in vsftpd.conf?

Replace the settings below in the config file (add any that are missing). They disable anonymous access, jail every local user to their home directory, require TLS for both login and data, and pin passive mode to a known port range:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
chroot_local_user=YES
allow_writeable_chroot=NO

userlist_enable=YES
userlist_file=/etc/vsftpd.userlist
userlist_deny=NO

ssl_enable=YES
rsa_cert_file=/etc/letsencrypt/live/ftp.example.net/fullchain.pem
rsa_private_key_file=/etc/letsencrypt/live/ftp.example.net/privkey.pem
allow_anon_ssl=NO
force_local_logins_ssl=YES
force_local_data_ssl=YES
ssl_ciphers=HIGH
require_ssl_reuse=NO

pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40100

xferlog_enable=YES
log_ftp_protocol=NO

With userlist_deny=NO, only accounts listed in /etc/vsftpd.userlist can log in at all, so root and your admin user stay locked out of FTP. require_ssl_reuse=NO keeps common clients working; some of them open the data channel without reusing the TLS session. Leave listen and listen_ipv6 as the package set them: the default listens on IPv4 and IPv6 together.

How do you create an FTP-only user?

Create a user that can log in to FTP but not to a shell. The home directory becomes the chroot, which vsftpd requires to be not writable by the user, so give them a writable folder inside it:

sudo useradd -m -d /srv/ftp/uploader -s /usr/sbin/nologin uploader
sudo passwd uploader
sudo chown root:root /srv/ftp/uploader
sudo chmod 755 /srv/ftp/uploader
sudo mkdir /srv/ftp/uploader/files
sudo chown uploader:uploader /srv/ftp/uploader/files

echo uploader | sudo tee -a /etc/vsftpd.userlist
grep -qx /usr/sbin/nologin /etc/shells || echo /usr/sbin/nologin | sudo tee -a /etc/shells

The last line matters because the vsftpd PAM stack checks that the account's shell appears in /etc/shells; nologin still refuses SSH logins. On Rocky and Alma, let SELinux allow FTP writes to normal directories:

sudo setsebool -P ftpd_full_access on
sudo systemctl restart vsftpd

For a backup drop box where files must never be deleted over FTP, add cmds_denied=DELE,RMD,RNFR to the config: uploads still work, but deletes and renames are refused.

Which firewall ports does FTPS need?

Open port 21 for the control channel and the whole passive range for data. Because the control channel is encrypted, the firewall cannot read it to open data ports on the fly the way connection-tracking helpers do for plain FTP, so the range must be allowed explicitly:

# Ubuntu and Debian with UFW
sudo ufw allow 21/tcp
sudo ufw allow 40000:40100/tcp
sudo ufw status

# Rocky and Alma with firewalld
sudo firewall-cmd --permanent --add-port=21/tcp
sudo firewall-cmd --permanent --add-port=40000-40100/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports

A hundred ports allow plenty of simultaneous transfers. Shrink the range if only one or two people ever connect. The firewall tutorial explains the general OS firewall layout on your server.

How do you test the setup?

Test from another machine with curl, which supports explicit FTPS through --ssl-reqd, then upload a file:

curl --ssl-reqd --user uploader ftp://ftp.example.net/files/
echo hello > test.txt
curl --ssl-reqd --user uploader -T test.txt ftp://ftp.example.net/files/
curl --user uploader ftp://ftp.example.net/files/

The first two should succeed after the password prompt. The last one, without TLS, must be refused with a message that encryption is required. In a graphical client, choose "Require explicit FTP over TLS" as the encryption mode and passive transfer mode. On the server, follow sudo tail -f /var/log/vsftpd.log to watch uploads arrive.

What causes most FTPS problems?

  • Login works, directory listing hangs: passive ports are closed in the firewall, or the client uses active mode. Check both.
  • 500 OOPS: vsftpd: refusing to run with writable root inside chroot(): the user owns their home directory. Make it root owned and use a subfolder for writes.
  • 530 Login incorrect for a valid password: the user is missing from /etc/vsftpd.userlist, or their shell is not in /etc/shells.
  • Service fails after renewal: the certificate path is wrong or the deploy hook did not run. Check journalctl -u vsftpd.
  • Permission denied on Rocky or Alma: the SELinux boolean is off.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
S1-2a small upload box with SSD space1 vCPU, 2 GB RAM, 55 GB SSD$6.00/mo$72.00 for 12 months
A1-2FTPS next to a web server1 vCPU, 2 GB RAM, 50 GB NVMe$7.20/mo$43.20 for 6 months

Questions about Encrypted FTP with vsftpd (FTPS)

What is the difference between explicit and implicit FTPS?

Explicit FTPS starts as normal FTP on port 21 and upgrades with AUTH TLS. Implicit FTPS expects TLS from the first byte on port 990 and is considered legacy. Use explicit unless a client only supports implicit.

Can I use a self-signed certificate?

It encrypts the traffic, but clients cannot verify the server and will warn on every connection. A free Let's Encrypt certificate removes that problem.

Can FTP users upload straight into a website folder?

Yes. Set local_root=/var/www/example.net/public in a per-user config file and make sure the web server can read what they upload. Keep the chroot rule in place.

Is port 21 enough if I use active mode?

Active mode has the server connect back to the client, which most home routers block. Passive mode with an open range is the reliable choice.

Why not simply use SFTP?

If your client supports it, do. It needs only the SSH port and no certificate. FTPS exists for software that cannot speak SFTP.