When you manage a website or server, you may need direct access to upload, download, or manage files. That’s where FTP (File Transfer Protocol) becomes useful.
FTP allows you to securely and efficiently transfer files between your local computer and a Linux server. Whether you’re uploading website files, managing backups, or sharing data internally, correctly configuring FTP ensures smooth file management.
In this guide, we will explain how to set up FTP on a Linux server in a simple, step-by-step way. We will use one of the most popular and secure FTP servers, vsftpd, because it’s lightweight, stable, and widely supported.
Also Read: How To Access a Linux Server Using PuTTY SSH Terminal?
What is vsftpd?
vsftpd stands for “Very Secure FTP Daemon.”
It is:
- Fast and lightweight.
- Secure by default.
- Easy to configure.
- Suitable for both beginners and advanced users.
Also Read: How to Create a User in Linux & Add it to the sudoer File?
Step-by-Step Guide to Setting Up FTP on Linux
The commands below work on Ubuntu/Debian-based systems. For CentOS/RHEL, the commands differ slightly (we will note them where needed).
➢ Step 1: Update Your Server
Before installing any new software, it is always recommended to update your system.
Updating ensures:
- You have the latest security patches.
- Package dependencies are up to date.
- Installation errors are minimized.
For this, you have to run:
| sudo apt update sudo apt upgrade -y |
If you are using CentOS/RHEL:
| sudo yum update -y |
This prepares your server for a clean and stable installation.
➢ Step 2: Install vsftpd
Now, you need to install the FTP server software.
On Ubuntu/Debian:
| sudo apt install vsftpd -y |
On CentOS/RHEL:
| sudo yum install vsftpd -y |
What this does:
- Downloads the vsftpd package from the official repositories
- Installs required dependencies
- Sets up the FTP service on your system
After installation, the service file is automatically created.
➢ Step 3: Start and Enable the FTP Service
After installation, the FTP service must be started manually.
➔ Start the service:
| sudo systemctl start vsftpd |
This command immediately activates the FTP server.
➔ Enable it at boot:
| sudo systemctl enable vsftpd |
This ensures FTP starts automatically whenever the server restarts.
To confirm it’s running:
| sudo systemctl status vsftpd |
If you see active (running), your FTP server is successfully running!
➢ Step 4: Configure FTP Settings
The main configuration file for vsftpd is located at:
| /etc/vsftpd.conf |
➔ You have to Open it:
| sudo nano /etc/vsftpd.conf |
This file controls how your FTP server behaves.
Important Settings to Configure:
Make sure these lines exist and are set correctly:
| anonymous_enable=NO local_enable=YES write_enable=YES chroot_local_user=YES |
What Each Setting Means:
- anonymous_enable=NO
It disables anonymous login. This prevents unknown users from accessing your server.
- local_enable=YES
It allows existing Linux users to log in using their system username and password.
- write_enable=YES
It allows users to upload, edit, and delete files.
- chroot_local_user=YES
It restricts users to their own home directory. This improves security by preventing access to other system folders.
➔ After editing:
- Press ‘CTRL + X’
- Press ‘Y’
- Press ‘Enter’
Restart the service to apply changes:
| sudo systemctl restart vsftpd |
➢ Step 5: Create an FTP User
For security reasons, you should not use the root account for FTP access.
Create a new user:
| sudo adduser ftpuser |
You will be prompted to set a password.
This user:
- Gets a home directory (e.g., /home/ftpuser)
- Can log in via FTP
- Is restricted to their own folder (if chroot is enabled)
Set correct permissions:
| sudo chmod 755 /home/ftpuser |
This ensures the folder is accessible but not insecure.
➢ Step 6: Configure the Firewall
If your firewall is active, FTP connections may be blocked by default.
For Ubuntu (UFW):
| sudo ufw allow 20/tcp sudo ufw allow 21/tcp sudo ufw allow 40000:50000/tcp sudo ufw reload |
Explanation:
- Port 21 is used for FTP control connection
- Port 20 is used for data transfer (active mode)
- Ports 40000–50000 are for passive mode connections
For CentOS (firewalld):
| sudo firewall-cmd –permanent –add-service=ftp sudo firewall-cmd –reload |
Without opening these ports, clients won’t be able to connect.
➢ Step 7: Enable Passive Mode (Recommended)
Passive mode improves compatibility, especially when clients are behind firewalls or NAT.
➔ Open the config file again:
| sudo nano /etc/vsftpd.conf |
➔ You have to add:
| sudo systemctl restart vsftpd |
➔ Restart the service:
| sudo systemctl restart vsftpd |
Now your server properly supports passive FTP connections.
➢ Step 8: Test the FTP Connection
You have to use an FTP client such as:
- FileZilla
- WinSCP
- Command-line FTP
You have to enter:
- Host: Your server IP address
- Username: ftpuser
- Password: (your password)
- Port: 21
If the login is successful, your FTP server is working correctly.
Also Read: Common FTP Errors With Solutions Important to Know
Security Recommendations
Traditional FTP does not encrypt data. That means usernames and passwords can be visible during transfer.
For better security:
- Use FTPS (FTP over SSL)
- Or use SFTP (via SSH) instead of standard FTP
- Never allow anonymous login
- Avoid root access via FTP
- Use strong passwords
For production servers, SFTP is usually the safest option.
Also Read: How To Get FTP Password From FileZilla
Conclusion
Setting up FTP on Linux is a straightforward process when done step by step. By installing and properly configuring vsftpd, you create a secure and controlled environment for file transfers.
The most important parts of the setup are:
- Proper configuration of the vsftpd file.
- Creating a separate FTP user.
- Securing your server with firewall rules.
- Restricting users to their own directories.
Once everything is configured correctly, FTP becomes a powerful and convenient tool for managing server files remotely.
With the right setup and security measures, you can ensure smooth, safe, and professional file management on your Linux server.
