Linux

How to install FTP and configure FTP on an Ubuntu 22 LTS instance

Instal FTP on your Ubuntu VPS

If you need to upload files to your NVMe VPS you have a couple of options. You can use a program like WinSCP to connect over SSH and upload files. This can be time-consuming. Or you can install FTP on Ubuntu. We will go through the whole process of installing FTP on an Ubuntu VPS and also how to configure FTP so you can upload files and folders. You should have an Ubuntu or Debian-based system already installed. You can install this from the discovery control panel.

Install FTP On Ubuntu

First, install vsftpd on your instance with the following commands.

apt install vsftpd

Now you have your FTP server installed it’s time to configure its settings. But there are a number of security issues you will want to take into account. In our configuration, we are locking FTP users to specific directories and disabling SSH access for these users.

Configure FTP

So, the configuration settings are stored in the /etc/vsftpd.conf file. Open that file and let’s start configuring FTP.

nano /etc/vsftpd.conf

In this file, change the following statements;

anonymous_enable=NO
local_enable=YES

# Enable uploads
write_enable=YES

# To stop users browing files outside of their directory. Read the 
# chroot_local_user section below for more information.
chroot_local_user=YES

# Set Passive Ports. Remember to open in any firewalls.
pasv_enable=YES
pasv_min_port=32000
pasv_max_port=35000

# Create and Enable Access List. Usernames must be placed in the userlist
# file
userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO

chroot_local_user

This option stops users from browsing outside of their home directory. When you enable this option you cannot upload files to the home directory because it is writeable. To resolve this you have two options.

  • Specifically, specify the user’s upload directory. The below statement would allow uploads to the /home/user directory
user_sub_token=$USER
local_root=/home/$USER/
  • Specify the allow-writeable-chroot directive. This is the default. Should be used in addition to the above.
allow_writeable_chroot=YES

Restart VSFTPD

Finally, restart the FTP service.

systemctl restart vsftpd

Configure Firewall

After installing FTP and going through the configuration you need to enable FTP access in your firewall. If you are using UFW the commands are below. If you are using our network firewall, just add the ports in your client area.

ufw allow 20:21/tcp
ufw allow 32000:35000/tcp
ufw disable
ufw enable

That’s the process complete. You should now be able to FTP to your instance and upload files and folders. But if you wanted to, you could also configure an SSL to secure connections over FTP. That’s outside the bounds of this guide but a quick search on Google should produce a lot of results.

Related Articles

Leave a Reply

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

Back to top button