Ubuntu Linux

How to Setup FTP Server in Ubuntu 18.04 with Vsftpd

FTP is a way to transfer files between two computers. One of the oldest method and FTP is the most common way to transfer files in internet.

This tutorial explains how to install FTP Server on Ubuntu 18.04. To setup FTP server on Ubuntu, we need to install an FTP server software. Vsftpd which stands for very secure FTP daemon it the best FTP solution for Ubuntu 18.04.

To setup FTP Server, login to your Ubuntu command line and perform the following steps with root privileges.

  1. Install vsftpd with the apt-get command:
    apt-get update
    apt-get install vsftpd
  2. After installation, open the /etc/vsftpd.conf file.
  3. Make Sure, that anonymous_enable is set to no and local_enable is set to yes:
    anonymous_enable=NO
    local_enable=YES
  4. Uncomment (remove the # at the beginning of the line) the write_enable line and make sure that its value is set to YES:
    write_enable=YES
  5. Find and uncomment: chroot_local_user=YES:
    chroot_local_user=YES
  6. Next, add the following line to allow  writable chroot:
    allow_writeable_chroot=YES
  7. Finally, save the vsftpd.conf and restart the vsftpd service:
    systemctl restart vsftpd.service

Now that we have configured FTP server on Ubuntu 18.04, you can use an FTP client (e.g. FileZilla) to access the FTP server from a remote computer.

(Note that if your Ubuntu server is behind a firewall, you need to open FTP port 21 on the firewall)

Enable FTP Passive Mode

When connecting to the FTP server, the FTP client will use either active mode (default) or passive mode. If the client is behind a firewall (e.g. Windows firewall on Windows) active mode will not work and the FTP client will switch to passive mode. In that case FTP Passive Mode must be enabled on our Ubuntu FTP server.

To enable FTP Passive Mode, open the /etc/vsftpd.conf.

  1. Add the line pasv_enable=Yes:
    pasv_enable=Yes
  2. Define a range of ports that will be used for the data connection:
    pasv_min_port=10090
    pasv_max_port=10100
  3. Restart the FTP server:
    systemctl restart vsftpd.service

(Note that if the Ubuntu server is behind a firewall, you need to open the port range defined in the configuration along with the FTP port 21.)

Start, Stop and restart FTP server

You can start, stop and restart vsftpd server on Ubuntu with systemctl command, for example to stop the FTP server, run:

systemctl stop vsftpd

By default vsftpd is set to start automatically, if not, run:

systemctl enable vsftpd

If you don’t want to start the server automatically, run:

systemctl disable vsftpd

To view the server status, run:

systemctl status vsftpd
Start, Stop and restart FTP server on Ubuntu 18.04