FTP, or File Transfer Protocol, is a standard network protocol used for the transfer of computer files between a client and server on a computer network. In this guide, we will discuss how to create an FTP user for your web server using
vsftpd, a fast and secure FTP server for UNIX-like systems.
To create an FTP user for your web server using vsftpd, you need to configure vsftpd to enable local users and allow them to write to files. Then, create a new user using the useradd command and set a password for them. Finally, restrict the FTP user to their home directory for security purposes.
Before we begin, make sure you have the following:
- A Linux-based server with
vsftpdinstalled. If you haven’t installed it yet, you can do so using the command
sudo apt-get install vsftpdon Ubuntu or
sudo yum install vsftpdon CentOS.
- Root or sudo access to your server.
Step 1: Configuring vsftpd
First, we need to configure
vsftpd to enable local users and allow them to write to files.
- Open the
vsftpdconfiguration file with the command:
sudo nano /etc/vsftpd.conf
This command uses
nano, a command-line text editor, to open the configuration file. You can replace
nano with your preferred text editor.
- In the configuration file, find and uncomment the following lines by removing the
Here’s what these parameters do:
local_enable=YES: This allows local users to log in to the FTP server.
write_enable=YES: This allows any FTP user to write to files.
chroot_list_enable=YES: This restricts users to their home directories.
- Save your changes and exit the text editor. In
nano, you can do this by pressing
Ctrl + X, then
Yto confirm saving the changes, and then
Enterto confirm the file name.
Step 2: Creating the FTP User
Next, we will create a new user who will have access to the FTP server.
- Use the
useraddcommand to add a new user. Replace
usernamewith the desired username:
sudo useradd -m username
-m option creates a home directory for the user.
- Set a password for the new user with the
sudo passwd username
You will be prompted to enter and confirm the password.
Step 3: Restricting the FTP User to Their Home Directory
For security reasons, it’s a good practice to restrict FTP users to their home directories. This way, they can’t navigate to other directories on the server.
- Create a new file named
sudo touch /etc/vsftpd.chroot_list
- Open the
vsftpd.chroot_listfile and add the username of the FTP user:
sudo nano /etc/vsftpd.chroot_list
Add the username to the file, save your changes, and exit the text editor.
Step 4: Restarting vsftpd
Finally, for the changes to take effect, restart the
sudo service vsftpd restart
That’s it! You’ve successfully created an FTP user for your web server using
vsftpd. The user is now able to log in to the FTP server with their username and password and can write to files in their home directory.
Remember, FTP is inherently insecure because it transmits data in plaintext. Consider using SFTP (Secure FTP) or FTPS (FTP over SSL), which encrypt the data, for a more secure file transfer. You can enable SFTP or FTPS in the
vsftpd configuration file.
For more information on
vsftpd, refer to the official vsftpd documentation.
vsftpd stands for Very Secure FTP Daemon. It is a fast and secure FTP server for UNIX-like systems.
You can install
vsftpd on Ubuntu by running the command
sudo apt-get install vsftpd. On CentOS, you can use the command
sudo yum install vsftpd.
You can open the
vsftpd configuration file using the command
sudo nano /etc/vsftpd.conf. Replace
nano with your preferred text editor if needed.
local_enable=YES allows local users to log in to the FTP server.
To create a new FTP user, use the command
sudo useradd -m username. Replace
username with the desired username.
You can set a password for the new FTP user using the command
sudo passwd username. Replace
username with the actual username.
To restrict the FTP user to their home directory, create a file named
vsftpd.chroot_list using the command
sudo touch /etc/vsftpd.chroot_list. Then, open the file with a text editor using the command
sudo nano /etc/vsftpd.chroot_list and add the username of the FTP user.
You can restart the
vsftpd service by running the command
sudo service vsftpd restart.
No, FTP is inherently insecure as it transmits data in plaintext. It is recommended to use SFTP (Secure FTP) or FTPS (FTP over SSL) for a more secure file transfer.
For more information on
vsftpd, you can refer to the official vsftpd documentation.