Matomo Analytics

While we do recommend to use SFTP instead of FTP, there might be use-cases you want to install a FTP server yourself.

When you do want to install a FTP server, we recommend to use the VSFTPD software.

Make sure when you start with this guide, you are logged in as a root user.

Run these commands:

apt update
apt -y install vsftpd
systemctl start vsftp
systemctl enable vsftpd
mv /etc/vsftpd.conf /etc/vsftpd.conf.orig

Next edit /etc/vsftpd.conf

nano /etc/vsftpd.conf

And put these contents:

listen=NO
listen_ipv6=YES
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_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO
pasv_enable=Yes
pasv_min_port=4242
pasv_max_port=4243
allow_writeable_chroot=YES

After that, we'll have to configure the firewall to allow the FTP protocol and directory listing.

Allow these ports:

  • 21 TCP
  • 4242:4243 TCP

Now this is all done, restart the FTP server for the last time and try it out.

service vsftpd restart
Dennis Smink

Written by Dennis Smink

Dennis brings over 6 years of hands-on experience in server management, specializing in optimizing web services for scalability and security.

Start free trial