File Server – Part 3 FTP

Published on October 24, 2021 at 7:36 am by LEW

Introduction

In this post we will discuss installing the FTP software on our base Debian build. I am making the assumption this is going to be installed on a LAN and not have access to the internet, so we will leave discussing any firewalls or additional security for another time, as that is a topic unto itself.

I am also not going to recite a security lecture. I will simply say basic FTP is not secure. But if you are using it on your own local network where you are the only user, then it is not much of an issue. If other people have access you may want to default to SFTP.

Setting up the Base Build

I am going to use the base Debian build for this server, with the following modifications.

When partitioning the hard drive, I am going to select the “use entire disk” option, then then the creates a “separate /home partition” option. This should set up a small root partition, a swap partition, and a large home partition. There may also be an EFI partition if using UEFI.

Configure the Network

Before installing any software we must configure the network interface. On the current Debian build (version 11 code named Bullseye as of this writing) the network configuration file is located at /etc/network/interfaces. You will need root permissions to write this file.

Opening the file in your favorite text editor (nano or vim by default in Debian) you will see that the local loopback is defined first, then the network interface. Debian has used Predictable Network Names for the last several releases. This means your network names will not be the same as my network names, unless we are using identical computers. On my setup the network adapter is called enp0s3. So that is what I will be using in my example.

By default the network adapter should be setup as allow-hotplug and dhcp. The allow-hotplug option will only setup the network adapter if something connects. So instead we will use the auto option.

We will also replace the dhcp option with the static option. Doing this will require that we define a network address, subnet mask, and gateway.

In your interfaces file, your network interface configuration should be similar to the below, with adjustments for your local network.

Auto enp0s3
iface enp0s3 inet static
address 192.168.2.2
netmask 255.255.255.0
gateway 192.168.2.1

The easiest way to get the new settings to take effect is to restart your computer. To check your settings type ip a.

Installing the Software

There are several FTP server packages that can be installed on a Debian build. We will be using the vsftpd (Very Secure FTP Daemon) package. This program will run as a daemon. In computer terms a daemon is a program that is always running in the background and does not need direct user interaction. To install we simply type the following.

apt install vsftpd

Once installed we can type the following to verify the version.

vsftpd -version

To check if the program running in the background you can type the following.

systemctl status vsftpd

If you do a restart and find the program is not running, then you can set it to auto start on boot with the following command.

systemctl enable vsftpd

Testing vsftpd

Before testing we will want to add a file to our home directory. Use the cd command to move to your home directory, then use the touch command to create an empty file. For example if our user name is “john” then we would do the following.

cd /home/john
touch test1

The vsftpd program in Debian should work out of the box with no additional configuration. To test this you can open a command line on another computer connected to your local network and type in the command “ftp”. This should start the built in command line FTP client on most operating systems. You will want to log in and list directory content. You will need to check specifics for the operating system documentation but in general the process should look like the following.

C:\Users\John>ftp
ftp> open
To 192.168.2.2
Connected to 192.168.2.2.
220 (vsFTPd 3.0.3)
200 Always in UTF8 mode.
User (192.168.2.2:(none)): john
331 Please specify the password.
Password:
230 Login successful.
ftp> dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r–r– 1 0 0 0 Oct 24 06:49 test1
226 Directory send OK.
ftp: 66 bytes received in 0.00Seconds 33.00Kbytes/sec.
ftp>

Final Notes

This installation is not very secure. If it is on your personal network, and you are the only user it is good enough. However you may want to take some time and browse the vsftpd and vsftpd.conf man pages if others will be using this installation.

Most popular modern browsers have dropped FTP support. For a GUI consider installing one of the many FTP client programs like Filezilla for example.

Conclusion

Having done a basic FTP Server install, you should now be able to store files on your file server and access them from any device with a FTP client program running though your local network.

Having common storage means your files will be available to all devices without having to physically transfer them.

Next time we will look at setting up a Samba server as another way to remotely access files.

File Server Part 1 Some Basics

File Server Part 2 Design

File Server Part 3 FTP

File Server Part 4 SAMBA

 

Add New Comment

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