How to restrict vsftpd FTP user to home/default folder in Linux server

Abstract: Prevents vsftpd users from accessing system directories by enforcing a chroot jail to their home folder.

Created: 2026-08-04 by
To restrict a vsftpd FTP user to their home directory in Linux, you must enable the chroot jail feature by setting chroot_local_user=YES in the /etc/vsftpd.conf file. This configuration forces all local users to remain within their assigned home folder upon login, preventing access to system directories like /etc or /usr. After modifying the configuration file, restart the vsftpd service to apply the changes and ensure your server security is hardened against unauthorized directory traversal.

Understanding the Security Risk

By default, many FTP daemons allow users to navigate up the directory tree using the parent directory command (..). In a standard vsftpd installation without proper restrictions, an authenticated user could potentially browse to / (the root) and view sensitive system files. This poses a significant security risk, especially if the FTP account is shared among multiple developers or clients who should only interact with their specific project folders. Restricting users to their home directory eliminates this attack vector, ensuring that each user has isolated storage and cannot interfere with other users' data or critical system configurations.

Configuring vsftpd for Chroot Jail

The primary method to enforce this restriction is through the main configuration file located at /etc/vsftpd.conf. You need to locate or add the directive that controls the chroot behavior. Set the following parameter:
chroot_local_user=YES
This setting tells vsftpd to change the root directory of the session to the user's home directory immediately after authentication. It effectively creates a "jail" where the user perceives their home directory as the root of the filesystem. However, modern versions of vsftpd require additional safeguards because allowing write access inside a chrooted environment can be dangerous if not handled correctly. To maintain compatibility while keeping security high, it is often recommended to keep chroot_local_user=YES but also ensure that the user's home directory is not writable by the user if they are listed in the chroot_list_file, or alternatively, use a whitelist approach. For a more granular control, you might prefer to set chroot_local_user=NO and instead define a list of users who *should* be jailed. Create or edit the file referenced by chroot_list_file=/etc/vsftpd.chroot_list and add usernames to this file. Users in this list will be chrooted, while those not in the list will have full filesystem access. This is useful if you have some trusted administrators who need broader access while restricting regular users.

Handling Write Permissions in Chroot

A common issue arises when users are chrooted into their home directory but also need to upload files. If the home directory is owned by the user and writable, vsftpd may reject the connection due to security policies introduced in version 3.0.0. To resolve this, you can either make the home directory non-writable and create a separate writable subdirectory, or configure vsftpd to allow write access explicitly. If you choose to keep the home directory writable, ensure that the allow_writeable_chroot=YES directive is added to /etc/vsftpd.conf. This setting explicitly permits vsftpd to operate in a writable chroot environment, acknowledging the slight increase in risk for the convenience of easier user management. Without this flag, users might encounter errors such as "500 OOPS: vsftpd: refusing to run with writable root inside chroot()". Alternatively, a more secure approach involves creating a dedicated upload directory. Keep the home directory read-only for the user and create a subdirectory named uploads or public_html that the user owns. Configure the application or script to save files to this subdirectory. This ensures that even if the user is chrooted, they cannot modify the structure of their home directory itself.

Applying Changes and Troubleshooting

After editing /etc/vsftpd.conf, you must reload the service for changes to take effect. The command varies depending on your Linux distribution. On systemd-based systems like Ubuntu, Debian, or CentOS 7+, use:
sudo systemctl restart vsftpd
On older SysVinit systems, use:
sudo service vsftpd restart
Always verify the status of the service using systemctl status vsftpd to ensure it started without errors. If the service fails to start, check the logs at /var/log/syslog or /var/log/messages for syntax errors in the configuration file. Common mistakes include typos in directive names or missing values for parameters. If users report that they cannot navigate at all or receive connection drops, refer to our guide on VSFTPD Silently Drops Connection - Troubleshooting Guide. This resource covers issues related to PAM modules and network timeouts that might mimic chroot failures. Additionally, if you are seeing configuration parse errors, consult Troubleshooting vsftpd Configuration Issues for detailed steps on validating your setup.

Verifying the Restriction

To confirm that the restriction is working, log in with the restricted user account using an FTP client. Attempt to navigate to the parent directory using the .. command. If the configuration is correct, the client should either display an error message indicating that the directory does not exist or simply refuse to change directories, leaving the user in their home folder. You can also try listing files in /tmp or /etc; these operations should fail with permission denied or file not found errors, confirming that the chroot jail is active. For further insights on managing file permissions during uploads, particularly on CentOS systems, review Prevent Change File Owner/Group on CentOS using FileZilla FTP Upload Server. This complements the chroot setup by ensuring that uploaded files retain appropriate ownership settings.

Frequently Asked Questions

Why do I get a "writable root inside chroot" error?

This error occurs because vsftpd considers a writable chroot directory a potential security vulnerability. To fix it, add allow_writeable_chroot=YES to your configuration file, or make the home directory read-only and create a separate writable subdirectory for uploads.

Can I allow some users to escape the chroot jail?

Yes, by setting chroot_local_user=NO and adding specific usernames to the chroot_list_file. Users in this list will be chrooted, while others will have full filesystem access. Ensure the path to the list file is correctly defined in the config.

Does chroot affect SFTP connections?

No, vsftpd handles FTP and SFTP differently. The chroot_local_user setting applies specifically to the FTP protocol managed by vsftpd. SFTP usually relies on SSH daemon configurations (/etc/ssh/sshd_config) for directory restrictions, so you must configure them separately if needed.

How do I reset the password for a vsftpd user?

vsftpd typically uses system users for authentication. To reset a password, use the standard Linux command passwd username in the terminal. This updates the password in the system's shadow file, which vsftpd reads during authentication.

What if my FTP client cannot see any files after enabling chroot?

Ensure that the user has read permissions on their home directory. If the directory permissions are too restrictive (e.g., 700), the user might not be able to list contents. Use chmod 755 /home/username to allow reading and listing while maintaining security.
Tags: linux ftp vsftpd

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More