18 C
Texas
angeloma
Senior Writer and partner

How to set up an FTP server on Ubuntu 20.04?

Although FTP servers are not as popular as they once were, they can still be quite useful in large organizations. Especially if they are used on an intranet where there is greater security over these files. For that reason, in this post, I will show you how to set up an FTP server on Ubuntu 20.04.

The File Transfer Protocol is a protocol that allows two remote computers to share files over a network. Usually, this happens from a server computer to a client computer. Usually, this happens through ports 20 and 21

Companies that have an intranet for daily work, usually have an FTP server configured to make files available to everyone and in Ubuntu 20.04 it is easy to do so.

Creating an FTP server on Ubuntu 20.04

Several daemons allow you to create the FTP server, however, I consider the easiest and fastest to VSFTPD. Besides all this, it works without problems and without making too many strange configurations.

- Advertisement -

So, open a terminal and update the system.

:~$ sudo apt update
:~$ sudo apt upgrade

And now, install the VSFTPD daemon.

:~$ sudo apt install vsftpd
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
ssl-cert
Suggested packages:
openssl-blacklist
The following NEW packages will be installed:
ssl-cert vsftpd
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 132 kB of archives.
After this operation, 402 kB of additional disk space will be used.
Do you want to continue? [Y/n
1.- Install VSFPTD on Ubuntu 20.04
1.- Install VSFPTD on Ubuntu 20.04

Like all services in Debian, it will start by default. To see if it is running correctly, use systemctl.

:~$ sudo systemctl status vsftpd
● vsftpd.service - vsftpd FTP server
Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-05-17 02:34:40 UTC; 1min 17s ago
Main PID: 1337 (vsftpd)
Tasks: 1 (limit: 506)
Memory: 844.0K
CGroup: /system.slice/vsftpd.service
└─1337 /usr/sbin/vsftpd /etc/vsftpd.conf
May 17 02:34:40 osradar systemd[1]: Starting vsftpd FTP server…
May 17 02:34:40 osradar systemd[1]: Started vsftpd FTP server.
2.- FTP server status
2.- FTP server status

The demon already has a default configuration, but we have to modify it to our liking.

Let’s go for it.

Configuring the FTP server

All the VSFTPD configuration is in the /etc/vsftpd.conf file, so before modifying it is convenient to make a backup of it. In case something goes wrong, we can go back to the original and reverse any wrong we have done.

:~$ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak

If you display the contents of the file, you will see that it is very extensive. But that’s because it’s so well documented, it’s quite easy to understand.

Let’s start by having the server actively listen.

listen=YES

If you are not going to use IPv6 then you should disable the support:

listen_ipv6=NO

It is also not advisable to allow access to anonymous. Although sometimes it can be useful.

anonymous_enable=NO

By default, on an FTP server, a client can only download files and not upload them. However, it is a good idea to leave it active.

local_enable=YES
write_enable=YES

By default, FTP works by 20.

connect_from_port_20=YES

Although you can change it with this directive:

listen_port=XX

You can use the key combination CTRL + W to go directly to the line you are looking for.

When you are ready, save your changes with CTRL + O and close the file with CTRL + X.

Omitting the comments in the file should look like this:

listen=YES
listen_ipv6=NO
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
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

To display the file without the comments, run the following command:

:~$ sudo cat /etc/vsftpd.conf | grep -v "^#"
3.- Configuring the FTP server on Ubuntu 20.04
3.- Configuring the FTP server on Ubuntu 20.04

Creating a new FTP user

Now there is a new user for the FTP server. This user can be created from the same terminal.

:~$ sudo useradd -m user1

And then, assign him a password:

:~$ sudo passwd user1

So,now we can test the new FTP server on Ubuntu 20.04.

Testing the FTP server on Ubuntu 20.04

Now the moment of truth has arrived. Let’s try the FTP server.

One way is to open a terminal and try to access it with the ftp command and the server’s IP address.

:~$ ftp 192.168.250.20
Connected to 192.168.250.20.
220 (vsFTPd 3.0.3)
Name (192.168.250.20:angelo): user1
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

Once the connection to the server is established, you will be asked for the username and password.

If the login is correct you will already have access to download and upload files.

4.- Access to the FTP server
4.- Access to the FTP server

Another way is from the web browser of your preference to access the FTP server. In my case, I access the following address ftp://192.168.250.20 and it is required immediately to log in.

5.- Access to the FTP server using the web browser
5.- Access to the FTP server using the web browser

By writing correctly the credentials created, I can access the folder that this user has dedicated.

6.- FTP server on Ubuntu 20.04
6.- FTP server on Ubuntu 20.04

To take better advantage of FTP, it is convenient to install a tool such as Filezilla.

So, that’s it. The FTP server is alive.

Conclusion

An FTP server can be a great way to share files on a network. Especially if it’s for an organization or on an intranet. You saw that setting one up in Ubuntu 20.04 is a pretty simple thing.

Please share this post, join our Telegram channel and if you want buy us a coffee.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article