How to install FTP Server on Ubuntu

Whether you want to run an Ubuntu server or simply want to remotely copy files, setting up an Ubuntu FTP server is simple.

What is FTP Server?

FTP (File Transfer Protocol) is the system used to upload (set) or download (retrieve) files from a server. You may have used it without realizing it before, when retrieving files or uploading images to the web. Or you may have used an FTP client to connect directly to an FTP file server.

For this to happen, FTP server software must be installed on the remote file host.

Whether you are building a Linux home server, web server, game server or whatever server is suitable for your project, FTP is the simplest way to transfer data from one system to another.

 

Install a server on Ubuntu

Installing FTP server on Ubuntu is very simple. The best approach is probably vsftpd. Follow the steps below to install and configure FTP server on Ubuntu with vsftpd.

1. Install Vsftpd

You may already have vsftpd installed on your machine. To test it out, open a command line window and type:

sudo apt list --installed

Vsftpd could be near the bottom of the list. If you haven't already, just install with:

sudo apt install vsftpd 

Once installed, it's time to get started with configuring vsftpd. Let's start by making a copy of the original configuration file. If something goes wrong or mistaken, the default configuration can be restored.

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf_default

Once done, launch it with the command:

sudo systemctl start vsftpd 

Confirm the server is running with:

sudo systemctl enable vsftpd

With vsftpd installed, you can begin the setup.

 

2. Create FTP user

First you need an FTP user account. With this account, you can use any FTP client to access files stored on the server through vsftpd. In the terminal, enter:

sudo useradd –m username

With the username and password set, create a test file in your account's home directory to confirm that it works:

sudo password username

When you first connect to your FTP Ubuntu server, you will see testfile.txt.

cd /home/username sudo nano testfile.txt

3. Secure Ubuntu FTP server

However, before setting up the connection, you need to make sure that the FTP ports are open in Ubuntu. By default, they are closed for security reasons in ufw (Uncomplicated Firewall).

To allow access via port 20, use:

sudo ufw allow 20/tcp

If your distribution uses a different firewall or you have an alternative installed, check the documentation for open ports.

For users to upload and install files in the configuration file:

sudo nano /etc/vsftpd.conf

Look for write_enabled and uncomment the entry, make sure it's set to "YES":

write_enable=YES

Press Ctrl + X to exit and Y to save.

For publicly accessible FTP servers, you will want to limit access per user. chroot can limit each user in its home directory. In vsftpd.conf, find and uncomment this line (uncomment the #):

chroot_local_user=YES

Press Ctrl + X to exit, Y to save.

For many users, creating a list is a smart choice.

First, open vsftpd.chroot_list in a text editor.

sudo nano /etc/ vsftpd.chroot_list

Here, list the usernames you want to limit in their own folders. Save and exit, then go back to vsftpd.conf and make sure chroot_local_user = YES uncommented:

#chroot_local_user=YES

Instead, uncomment:

chroot_list_enable=YES

and

chroot_list_file=/etc/vsftpd.chroot_list

The result will look like this:

Picture 1 of How to install FTP Server on Ubuntu

Continue, save and exit. Finally, restart the FTP service:

sudo systemctl restart vsftpd.service

Finally, use the hostname command to check the name of your Ubuntu server. You can then use it to connect to the FTP server. If you prefer to use an IP address, enter the command ip address and make a note of it.

4. Connection encryption: FTP + SSL = FTPS

You can also force encryption of traffic to and from your FTP Ubuntu server using SSL / TLS.

In the vsftpd.conf file look for "SSL encrypted connections" and add the following information:

ssl_enable=YES rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

Save and exit the file. Now you can specify FTPS as the connection protocol in your FTP client.

Update 31 August 2020
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile