How to Install and Configure vsftpd on Ubuntu 18.04

Installing a basic FTP server into Ubuntu 18.04 Bionic Beaver using vsftpd is a straightforward process. In this article we will cover installing the basic packages needed, setting up a user, setting up encryption, and then test connecting to it.

Install vsftpd

  1. Enter the Following Command to Install vsftpd
    sudo apt-get install vsftpd -y
  2. Start the vsftpd Service and Set It to Start on Boot
    sudo systemctl start vsftpd
    sudo systemctl enable vsftpd

Setup Directory Structure For FTP

  1. Create a User
    sudo adduser testuser1
  2. Create a Directory and Set Ownership
    sudo mkdir /home/testuser1/ftp
    sudo chown nobody:nogroup /home/testuser1/ftp
    sudo chmod a-w /home/testuser1/ftp
  3. Create a Directory Where Files Can Be Uploaded and Give Ownership to the Test User
    sudo mkdir /home/testuser1/ftp/test
    sudo chown testuser1:testuser1 /home/testuser1/ftp/test

Configure vsftpd

  1. Backup vsftpd’s Original Config File
    sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
  2. Open and Edit the vsftpd.conf File
    sudo nano /etc/vsftpd.conf
  3. Add the Following to the File:
    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
    pasv_enable=Yes
    pasv_min_port=10000
    pasv_max_port=11000
    user_sub_token=$USER
    local_root=/home/$USER/ftp
    userlist_enable=YES
    userlist_file=/etc/vsftpduserlist.conf
    userlist_deny=NO
  4. Save and Close the Config File
    vsftpd has many configuration options so you may need to make further adjustments based on your local server setup.
  5. Add The testuser1 User We Created to vsftpd’s User List File
    sudo nano /etc/vsftpduserlist.conf
  6. Restart the vsftpd Service to Apply These Changes
    sudo systemctl restart vsftpd

Setup Security with SSL/TLS

  1. Create a Security Certificate
    sudo mkdir /etc/certs
    
    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/certs/vsftpd.pem -out /etc/certs/vsftpd.pem
  2. Open the vsftpd.conf File
    sudo nano /etc/vsftpd.conf
  3. Add the Following Lines to the File
    rsa_cert_file=/etc/certs/vsftpd.pem
    rsa_private_key_file=/etc/certs/vsftpd.pem
    ssl_enable=YES
    allow_anon_ssl=NO
    force_local_data_ssl=YES
    force_local_logins_ssl=YES
    ssl_tlsv1=YES
    ssl_sslv2=NO
    ssl_sslv3=NO
    require_ssl_reuse=NO
    ssl_ciphers=HIGH
  4. Save the File and Restart vsftpd
    sudo systemctl restart vsftpd

To test, configure your favorite FTP client to connect to your server and make sure to set the encryption settings when you login.

You should see the FTP server contents upon login.

Check out these top 3 Linux hosting services

Was this article helpful?