FTP (File Transfer Protocol) is a popular method for transferring files between computers over a network. In Linux servers, vsftpd (Very Secure FTP Daemon) is a widely used FTP server software. By default, vsftpd allows FTP users to access their entire file system. However, in some cases, you may want to restrict FTP users to their home or default folder for security reasons. This article will guide you through the process of restricting vsftpd FTP users to their home/default folder in a Linux server.
Step 1: Install vsftpd
Before we begin, make sure that vsftpd is installed on your Linux server. If it is not already installed, you can install it by running the following commands in the terminal:
sudo apt update
sudo apt install vsftpd
Step 2: Configure vsftpd
Once vsftpd is installed, we need to configure it to restrict FTP users to their home/default folder.
Open the vsftpd configuration file in a text editor. In this example, we will use the nano editor:
sudo nano /etc/vsftpd.conf
Find the following line in the configuration file:
#chroot_local_user=YES
Remove the "#" symbol at the beginning of the line to uncomment it and enable the chroot_local_user option:
chroot_local_user=YES
Save the changes and exit the text editor.
Step 3: Restart vsftpd
After making the configuration changes, we need to restart the vsftpd service for the changes to take effect. Run the following command in the terminal:
sudo systemctl restart vsftpd
Step 4: Create FTP User
Now, let's create an FTP user and restrict them to their home/default folder.
Create a new system user using the adduser command. Replace "username" with the desired username:
sudo adduser username
Set a password for the user when prompted.
Step 5: Set Home/Default Folder
By default, vsftpd will restrict the FTP user to their home folder. If you want to change the default folder, you can do so by modifying the user's home directory.
To change the user's home directory, run the following command:
sudo usermod -d /path/to/folder username
Replace "/path/to/folder" with the desired folder path, and "username" with the actual username.
Step 6: Test FTP Access
Now, let's test the FTP access for the user and verify if they are restricted to their home/default folder.
Open an FTP client software on your local machine and connect to the Linux server using the FTP user credentials.
Once connected, you should only see the files and directories within the user's home/default folder. Attempting to navigate outside of this folder should result in an access denied error.
Conclusion
By following the steps outlined in this article, you can restrict vsftpd FTP users to their home/default folder in a Linux server. This helps to enhance the security of your server by preventing FTP users from accessing sensitive system files and directories.
If you encounter any issues or have any questions, feel free to consult the vsftpd documentation or seek assistance from your system administrator.
| Reference | Link |
|---|---|
| vsftpd Documentation | https://security.appspot.com/vsftpd.html |