How to Install and configure FTP server on Linux Mint / Ubuntu 20.04
FTP or the File Transfer Protocol is the most popular network protocol that is used to transfer files and information between two systems over a network. However, the FTP by default does not encrypt the traffic, which is not a secure method and can result in an attack on a server. This is where VSFTPD comes which stands for Very Secure FTP Daemon and is a secure, stable, and fast FTP server. VSFTPD is licensed under GNU GPL. For most of the Linux distributions, VSFTPD is used as a default FTP server. In this article, you will learn how to install and configure the FTP server on Linux Mint OS.
Note: We have explained the procedure and commands on Linux Mint 20 OS. More or less the same procedure can be followed in older Mint versions.
Installing FTP server
To install an FTP server on Linux Mint, follow the below steps:
Step 1: Install VSFTPD
Our first step will be to install VFTPD on our system. To do so, launch the Terminal in Mint OS by using the Ctrl+Alt+T keyboard shortcut. Then issue the following command in the Terminal to update the system repository index:
$ sudo apt update
Then install VSFTPD using the following command in Terminal:
$ sudo apt install -y vsftpd
Step 2: Configure VSFTPD
The VSFTPD can be configured through the /etc/vsftpd.conf file. Edit the /etc/vsftpd.conf file using the following command in Terminal:
$ sudo nano /etc/vsftpd
Now add or uncomment the following lines (if already added in the file):
listen=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
chroot_local_user=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=Yes
pasv_enable=Yes
pasv_min_port=10000
pasv_max_port=10100
allow_writeable_chroot=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
Once done, save and close the /etc/vsftpd.conf file.
Step 3: Allow ports in firewall
If a firewall is running on your system, you will need to allow some FTP ports through it. Issue the following commands in Terminal to allow the ports 20 and 21:
$ sudo ufw allow 20/tcp
$ sudo ufw allow 21/tcp
You can verify whether the port has been allowed in the firewall or not using the following command in Terminal:
$ sudo ufw status
Step 4: Enable and run VSFTPD
Now the VSFTPD is configured and allowed in the firewall; now we can enable and run the VSFTPD services. Here are the commands to do so:
To enable the VSFTPD service to start on boot, issue the following command in Terminal:
$ sudo systemctl enable vsftpd.service
To run the VSFTPD service, issue the following command in Terminal:
$ sudo systemctl start vsftpd.service
If you need to restart the VSFTPD service after making any configuration changes, issue the following command in Terminal:
$ sudo systemctl restart vsftpd.service
To verify if the VSFTPD is active and running, issue the following command in Terminal:
$ sudo systemctl status vsftpd.service
Step 5: Create an FTP user
Next, create a user account that will be used to test the FTP connection. Issue the following commands in Terminal to create a user account and set a password:
$ $ sudo adduser <username>
$ sudo passwd <username>
Step 6: Test FTP connection
Now our FTP server is ready, so it’s time to test the FTP connection.
To test FTP connection locally, issue the following command in Terminal by replacing the <ip-address> by the actual IP address of your FTP server:
$ ftp <ip-address>
You can also test the FTP connection remotely by using the same above command from the remote system. I have tested the FTP connection from the Windows machine on the network.
You can also use the FTP client like Filezilla to connect to the FTP server. To use the Filezilla application for connecting to the FTP server, provide the IP address of FTP server, username and password that you have set earlier, and port number 21 and then click the Quickconnect button.
Once connected, you will be successfully signed in to the FTP server and will be able to access remote server files and folders.
There you have the installation and configuration of the FTP server on the Linux Mint 20 system. By following the above described simple steps, you can easily setup the FTP server and transfer files through it.