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
|Category||Requirements, Conventions or Software Version Used|
|System||Installed or upgraded Ubuntu 20.04 Focal Fossa|
|Other||Privileged access to your Linux system as root or via the
# - requires given linux commands to be executed with root privileges either directly as a root user or by use of
- First, install VSFTPD on your system by typing this command into the terminal:
$ sudo apt-get install vsftpd
Configure FSFTPD server
- 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
- Create a new VSFTPD configuration file using nano or whichever text editor you prefer:
$ sudo nano /etc/vsftpd.conf
- 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:
Paste the above lines into your newly created
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
/etc/vsftpd.conffile, and then save changes and close the file.
- 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
- 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.
- 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
- 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"
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.
Connect to FTP server via CLI
- 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
ftpcommand 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
lscommand 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:
- Open Nautilus file manager from within the Applications menu.
- Click on "Other Locations" and enter
ftp://127.0.0.1in the "Connect to server" box at the bottom of the window and click connect.
- Enter the FTP account's credentials that we setup earlier and click connect.
- Upon a successful connection, you'll see the test file you created earlier.
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.