Linux is no fun unless you start using the command shell. It may take time to overcome the windows addiction, but sooner you do it, the more interesting is your journey with Linux. You can always install the FTP server from the Ubuntu package manager. It will install, leaving you wondering what happened and why. If you are a Linux geek, interested in playing with the command line, here is the one for you.
Let us dabble a bit on the shell, to setup your own FTP server.
Linux is often finicky about versions. But this is a simple and basic functionality that should work on most versions. But it is always advisable to stay updated with the most recent version. Before we start, it is advisable to ensure that all the existing packages and applications installed on our system are also updated.
For that, we have to invoke the Ubuntu package manager - "apt". This used to be "apt-get" but in recent versions, they have renamed it to just "apt". We run the two below commands to update the version table and then upgrade to the best permissible version for all the installed packages
sudo apt update sudo apt upgrade
The first command will run for some time, at the end, informing us if any upgrades are required. The second will actually download and install the updates. It will ask for confirmation before proceeding with the task.
Once we have everything ready, we can start off with the installation
VSFTPD stands for Very Secure FTP Daemon. As the name suggests, it is a daemon created to enable a secure FTP server. In this post, we will only check out a basics setup. If you like to dive deeper, you can refer this link for all the details you would need.
Before we start installation, it is wise to check if we already have it installed. And if it is, we need to make sure we do not overwrite some settings that another wise developer has already made for us. For this, we can check for any configuration file present on the server.
ls -l /etc/vsftpd.conf
If it file is already present there, it means that someone has already setup the vsftpd on the system. Nobody stops you from installing again. But, you may want to backup the settings before we overwrite it. So just make a copy of this vsftpd.conf file.
If it is not installed, the slate is clean for you to go ahead.
Now we start with actually installing the vsftpd. Again, we use the Ubuntu package manager. This ensures we do not install multiple or conflicting packages. We use the below command
sudo apt install vsftpd
It will calculate the packages that need to be installed and present us a summary of what would be downloaded and installed, and the memory it would consume on the disk. With the user's confirmation, the download and install will begin. If you have a decent internet connection, this should not take more than a minute.
Now, we just have the binary installed and available on the system. We need to start it as a daemon, and keep it running - so that it can process any incoming request. For this, we have to first create a service and then configure it to start on boot up.
sudo systemctl start vsftpd sudo systemctl enable vsftpd
These two commands do just that.
Normally, the firewall blocks the port 20, 21 - that are required for ftp and sftp. If we want to allow external entities to connect to the server via ftp, we have to open these ports on the firewall.
sudo ufw allow 20/tcp sudo ufw allow 21/tcp
This creates a basic FTP server - we can connect to it using the ftp command. This was a very basic introduction to the topic. There is a lot more that we can do with the vsftpd. Check out this link to get more details about its configuration.