In this guide, we will show you how to setup an FTP server using VSFTPD on Ubuntu 20.04 Focal Fossa.

VSFTPD is a popular choice for setting up FTP servers, and is the default FTP tool on a few Linux distributions. Follow along with us below to find out how to install the application and get your FTP server up and running.

In this tutorial you will learn:
  • How to install and configure VSFTPD
  • How to setup an FTP user account
  • How to connect to FTP server via command line
  • How to connect to FTP server via GUI
How to setup FTP server on Ubuntu 20.04 Focal Fossa Linux
How to setup FTP server on Ubuntu 20.04 Focal Fossa Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed or upgraded Ubuntu 20.04 Focal Fossa
Software VSFTPD
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

VSFTPD installation


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  1. First, install VSFTPD on your system by typing this command into the terminal:
    $ sudo apt-get install vsftpd
    

Configure FSFTPD server

  1. It's always best practice to keep a backup copy of the original config file, just in case something goes wrong later. Let's rename the default config file:
    $ sudo mv /etc/vsftpd.conf /etc/vsftpd.conf_orig
    
  2. Create a new VSFTPD configuration file using nano or whichever text editor you prefer:
    $ sudo nano /etc/vsftpd.conf
    
  3. Copy the following base configuration into your file. This configuration will suffice for a basic FTP server, and can later be tweaked for the specific needs of your environment once you've verified this is working properly:


    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=10000
    pasv_max_port=10100
    allow_writeable_chroot=YES
    
    Paste the above lines into your newly created /etc/vsftpd.conf file, and then save changes and close the file.
    VSFTPD configuration file
    VSFTPD configuration file
  4. Ubuntu's built-in firewall will block FTP traffic by default, but the following command will create an exception in UFW to allow the traffic:
    sudo ufw allow from any to any port 20,21,10000:10100 proto tcp
    


  5. With the configuration file saved and the firewall rules updated, restart VSFTPD to apply the new changes:
    $ sudo systemctl restart vsftpd
    

Create an FTP user

Our FTP server is ready to receive incoming connections, so now it's time to create a new user account that we'll use to connect to the FTP service.

  1. Use this first command to create a new account called ftpuser, and the second command to set a password for the account:
    $ sudo useradd -m ftpuser
    $ sudo passwd ftpuser
    New password: 
    Retype new password: 
    passwd: password updated successfully
    
  2. In order to verify that everything's working properly, you should store at least one file in ftpuser's home directory. This file should be visible when we login to FTP in the next steps.
    $ sudo bash -c "echo FTP TESTING > /home/ftpuser/FTP-TEST"
    
NOTE
FTP is not an encrypted protocol, and should only be used for accessing and transferring files on your local network. If you plan to accept connections from over the internet, it's recommended that you configure an SFTP server for additional security.

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Connect to FTP server via CLI

  1. You should now be able to connect to your FTP server either by IP address or hostname. To connect from command line and verify that everything is working, open a terminal and use Ubuntu's ftp command to connect to your loopback address (127.0.0.1).
    $ ftp 127.0.0.1
    Connected to 127.0.0.1.
    220 (vsFTPd 3.0.3)
    Name (127.0.0.1:user1): ftpuser
    331 Please specify the password.
    Password:
    230 Login successful.
    Remote system type is UNIX.
    Using binary mode to transfer files.
    ftp> ls
    200 PORT command successful. Consider using PASV.
    150 Here comes the directory listing.
    -rw-r--r--    1 0        0              12 Mar 04 22:41 FTP-TEST
    226 Directory send OK.
    ftp> 
    
    Your output should look like the text above, indicating a successful login and a ls command that reveals our test file we created earlier.

Connect to FTP server via GUI



You can also connect to your FTP server by GUI, if you prefer. There are many options for FTP clients, but the Nautilus file manager is a viable option that's installed by default in Ubuntu. Here's how to use it to connect to your FTP server:

  1. Open Nautilus file manager from within the Applications menu.
  2. Click on "Other Locations" and enter ftp://127.0.0.1 in the "Connect to server" box at the bottom of the window and click connect.
  3. Connect to FTP server with Nautilus
    Connect to FTP server with Nautilus
  4. Enter the FTP account's credentials that we setup earlier and click connect.
  5. Enter FTP credentials
    Enter FTP credentials
  6. Upon a successful connection, you'll see the test file you created earlier.


  7. Successful connection to FTP server
    Successful connection to FTP server

Conclusion

In this article, we saw how to use VSFTPD to create an FTP server on Ubuntu 20.04 Focal Fossa. We also covered how to use the command line and Ubuntu GUI to connect to the FTP server.

By following this guide, computers on your local network can access your system to store and retrieve files, either via the command line or their preferred FTP client.

FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions