I will set up an FTP server in my Ubuntu. At the end of the process, I will get an IP address, by which I will access the server. To know more about FTP, follow this article.
Here’s an step-by-step guide to setup an FTP server:
- First, press CTRL+ALT+T to launch an Ubuntu Terminal.
- Now write the command below to update the system:EXPLANATION
- apt-get update: Updates the local repository.
- Give your password (if necessary) and press ENTER.
Wait until the updating process is finished. - Copy the following command to install vsftpd package:Here I have installed the vsftpd package to set up the FTP server as it is fast, secure and it can handle a large number of connections efficiently. However, you can use other packages as well.EXPLANATION
- apt-get install: Install the given package.
- vsftpd: A popular open-source FTP server package.
- Then write the following command to open vsftpd.conf file:EXPLANATION
- nano: Opens a file in the Nano text editor.
- /etc/vsftpd.conf: Configuration file for “vsftpd”.
- Now edit the vsftpd.conf file like the below:
Note: You can write the lines or remove the hash (#) from the beginning if the lines already exist. Make sure there are no duplications.
EXPLANATION- write_enable: Determines whether users are allowed to upload files or not.
- pasv_min_port: Specifies the minimum port for passive mode.
- pasv_max_port: Specifies the maximum port for passive mode.
- Press CTRL+O and ENTER to save; CTRL+X to exist.
- Execute the following lines one by one to add rules to the Firewall:EXPLANATION
- ufw: Firewall of Ubuntu.
- allow: Allows incoming traffic on a given port.
- 20/tcp: Port 20 with TCP protocol which is used to transfer files in active mode.
- 21/tcp: Port 21 with TCP protocol which allows the server and client to communicate.
- from any to any port 40000:60000 proto tcp: Allows traffic from port 40000 to port 60000.
- Use the following two commands to restart the FTP server and see its status:EXPLANATION
- systemctl: Is used to control system services.
- restart: Restart a system service.
- status: Shows the current status of service.
- vsftpd: Name of the FTP service.
Your server is up and running if you see “active (running)” as in the image above. Well done! - Finally, insert the command below and hit ENTER to find the IP address of your FTP server:EXPLANATION
- ifconfig: Displays network interface parameters including IP address.
The IP address of my server is 192.168.235.129.Note: If your system doesn’t have “ifconfig”, use the following command to install it