How to Install FTP Server on Ubuntu with vsftpd

How to Install FTP Server on Ubuntu with vsftpd

Installing an FTP server on Ubuntu with vsftpd offers several key benefits. It enables file transfers between a client computer and a remote server. Users can upload, download, and organize files remotely. This is especially valuable for web developers, system administrators, and others who frequently manage large file transfers.

In this tutorial, you’ll learn how to set up an FTP server on Ubuntu with vsftpd (Very Secure FTP Daemon).

Setting Up an FTP Server on Ubuntu Using vsftpd

Vsftpd’s robust security features include SSL/TLS encryption. This ensures sensitive data is protected during file transfers. Follow the steps below to install the FTP Server on Ubuntu using Vsftpd:

Get Reliable Hosting with HostOnce’s Linux VPS

HostOnce’s Linux VPS lets you easily customize your hosting while offering strong performance, solid security, and stable uptime

Step 1: Update Ubuntu Repository

First, refresh the list of available software packages from the Ubuntu repositories.

sudo apt update
update system packages

Step 2: Install vsftpd

To get started, open your terminal and use the command below to install the vsftpd package on your Ubuntu system.

sudo apt install vsftpd
install vsftpd

After installation, the FTP service will automatically start. You can verify its status by using the command below.

sudo systemctl status vsftpd
verify vsftpd status

Step 3: Configure vsftpd

The configuration settings are stored in the /etc/vsftpd.conf. Therefore, you need to open and edit the file with an editor like Nano.

sudo nano /etc/vsftpd.conf
open vsftpd configuration file

3.1: Disable Anonymous Access

Find the anonymous_enable and set it to NO. This setting prevents the user from gaining access to a resource or service without providing authentication credentials.

anonymous_enable=NO
edit vftpd config file

3.2: Enable Local User Access

To let local users log in to the FTP server, find the local_enable setting in the configuration file and change its value to YES.

local_enable=YES
enable locla user access

3.3: Enable File Uploads

Also, you need to find and uncomment this line to allow users to upload files.

write_enable=YES
enable file uploads

3.4: Chroot Local Users

To restrict local users to their own home directories, locate the chroot_local_user setting in the config file and remove the # at the beginning to enable it.

chroot_local_user=YES
chroot local users

By default, vsftpd doesn’t allow file uploads to directories that have write permissions enabled. To fix this, create a separate FTP folder inside the user’s home directory.

mkdir -p /home/$USER/ftp/upload
create a new directory

Change the owner of the directory /home/$USER/ftp from the user nobody, to the group nogroup.

sudo chown nobody:nogroup /home/$USER/ftp
change directory owner

Remove write permissions for all users, including the owner, from the directory /home/$USER/ftp.

sudo chmod a-w /home/$USER/ftp
remove write permissions for all users

Next, give the current user ownership of the /home/$USER/ftp/upload folder by assigning both the user and their group to it.

sudo chown $USER:$USER /home/$USER/ftp/upload
change ownership to current user

Finally, copy the following lines into the vsftpd.conf:

user_sub_token=$USER
local_root=/home/$USER/ftp
update vsftpd configuration file

Note: You can also enable the allow_writeable_chroot directive by adding the following line to the configuration file.

allow_writeable_chroot=YES

After applying the required changes, restart the vsftpd service to make sure the new settings take effect.

sudo systemctl restart vsftpd

Set Firewall Settings for Ftp Server

You will need to allow FTP if the user has a firewall activated.

sudo ufw allow 20/tcp
update firewall

Use UFW to enable incoming network traffic on port 21 over the TCP protocol.

sudo ufw allow 21/tcp
allow traffic on port 21

Next, update the firewall rules using the following command to allow incoming connections on port 990, which is commonly used for secure FTP (FTPS).

sudo ufw allow 990/tcp
allow incoming connections on 990

Allow UFW to accept incoming network traffic from TCP ports 40000 to 50000 on a Linux System.

sudo ufw allow 40000:50000/tcp
allow incoming network traffic from tcp ports

Update the firewall using the following command once you have made changes to the rules.

sudo ufw reload

Test the FTP Server

Test the FTP server. Connect to the server using the IP address or localhost.

ftp localhost
test ftp server

Optional: Enable SSL/TLS

For secure file transfers, you can enable SSL/TLS. For this purpose, create an SSL certificate first:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.key -out /etc/ssl/certs/vsftpd.crt
enable ssl tls

Input the following lines in the vsftpd Configuration file.

ssl_enable=YES
rsa_cert_file=/etc/ssl/certs/vsftpd.crt
rsa_private_key_file=/etc/ssl/private/vsftpd.key
edit config file to enable ssl

After this, use the following command refresh the vsftpd service to apply the change.

sudo systemctl restart vsftpd
restart vsftpd

Finally, you now have a working FTP server set up on Ubuntu using vsftpd, ready to handle file transfers.

ftp localhost
run ftp server

This sums up the FTP server installation on Ubuntu.

Boost your Linux skills with step-by-step tutorials from our Knowledge Base.

Conclusion

Installing and enabling vsftpd is ideal for remote access, file backups, and secure file management. Its user management features allow creating multiple accounts with specific permissions, making it an efficient and secure file transfer tool. In this guide, we explained how to use vsftpd to install ftp on Ubuntu.

FAQs

Anyone who needs to manage or transfer large files, including web developers and system administrators, can benefit from an FTP server.

Vsftpd comes with a number of robust security features, including SSL/TLS, which encrypts data between client and server.

An FTP server lets users connect over the internet to access, download, or manage files from anywhere, making remote file handling simple and efficient. This is ideal for companies with remote employees or for individuals who want to access files on the road.

Yes, you can use an FTP server as a backup solution. It's a reliable way to store and access backup files remotely over the internet. Users can upload important files regularly to the server, protecting them from local data loss.

Vsftpd supports the creation of multiple accounts, each with its own permissions and controls. This makes it an extremely versatile and secure tool for managing and moving files.

Open the /etc/vsftpd.conf file and disable anonymous access.

Author: Anees Asghar

Anees is a seasoned technical writer and WordPress expert with over 5 years of experience building and optimizing WordPress solutions. He also writes on Windows, Linux, MySQL, Java, and other technologies, creating practical content that helps developers and IT professionals.

Post a Comment

Your email address will not be published. Required fields are marked *