<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux-Hardening on K-Life Hack | Systems Architecture &amp; DevOps</title><link>https://klifehack.com/en/tags/linux-hardening/</link><description>Recent content in Linux-Hardening on K-Life Hack | Systems Architecture &amp; DevOps</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Sat, 30 May 2026 17:33:07 +0900</lastBuildDate><atom:link href="https://klifehack.com/en/tags/linux-hardening/index.xml" rel="self" type="application/rss+xml"/><item><title>Deployment and Security Hardening of vsftpd on Enterprise Linux</title><link>https://klifehack.com/en/p/vsftpd-enterprise-linux-hardening/</link><pubDate>Sat, 30 May 2026 17:33:07 +0900</pubDate><guid>https://klifehack.com/en/p/vsftpd-enterprise-linux-hardening/</guid><description>&lt;h1 id="building-and-security-configuration-of-vsftpd-on-enterprise-linux-chroot-isolation-and-passive-mode-optimization"&gt;Building and Security Configuration of vsftpd on Enterprise Linux: chroot Isolation and Passive Mode Optimization
&lt;/h1&gt;&lt;p&gt;In Enterprise Linux distributions such as RHEL, CentOS, and Rocky Linux, &lt;b&gt;vsftpd&lt;/b&gt; (Very Secure FTP Daemon) is the standard implementation for FTP services. Its architecture is built on a security-first philosophy, utilizing a privilege separation model to mitigate risks. This guide details the configuration process, including service management, passive mode optimization, chroot-based user isolation, and firewall integration.&lt;/p&gt;
&lt;h2 id="1-package-installation-and-service-lifecycle-management"&gt;1. Package Installation and Service Lifecycle Management
&lt;/h2&gt;&lt;p&gt;The vsftpd daemon employs a Privilege Separation Model to reduce the attack surface by limiting the permissions of processes interacting with untrusted network data. The installation process begins with package acquisition via the system package manager.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Install vsftpd package&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo yum install -y vsftpd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Once installed, the service must be configured as a systemd unit to ensure it starts automatically during the boot sequence. Verification of the control port (TCP 21) ensures the daemon is correctly listening for incoming connections.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Start and enable the service&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl enable --now vsftpd
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Verify listening status on port 21&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo netstat -ntlp | grep &lt;span style="color:#ae81ff"&gt;21&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;netstat&lt;/code&gt; utility provides visibility into network statistics. The &lt;code&gt;-n&lt;/code&gt; flag enables numeric display, &lt;code&gt;-t&lt;/code&gt; specifies the TCP protocol, &lt;code&gt;-l&lt;/code&gt; filters for listening sockets, and &lt;code&gt;-p&lt;/code&gt; identifies the associated process IDs.&lt;/p&gt;
&lt;h2 id="2-vsftpdconf-configuration-and-passive-mode-optimization"&gt;2. vsftpd.conf Configuration and Passive Mode Optimization
&lt;/h2&gt;&lt;p&gt;FTP operations utilize active or passive modes. Passive mode (PASV) is preferred in modern environments to prevent connection blocks caused by client-side firewalls or NAT, as the client initiates the data connection. A backup of the original configuration is required before modification.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="definition-of-passive-mode-and-security-parameters"&gt;Definition of Passive Mode and Security Parameters
&lt;/h3&gt;&lt;p&gt;Modifying &lt;code&gt;/etc/vsftpd/vsftpd.conf&lt;/code&gt; allows for the definition of a specific port range for passive connections, facilitating granular firewall control.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;# Enable passive mode and define port range
pasv_enable=YES
pasv_min_port=50001
pasv_max_port=50010

# Configure user isolation settings
chroot_local_user=YES
allow_writeable_chroot=YES
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The &lt;code&gt;chroot_local_user=YES&lt;/code&gt; directive confines users to their home directories, preventing access to the system root. While vsftpd typically rejects logins if the chroot directory is writable, &lt;code&gt;allow_writeable_chroot=YES&lt;/code&gt; permits this configuration while maintaining the isolated environment. The service requires a restart to apply these changes.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart vsftpd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="3-network-access-control-via-firewalld"&gt;3. Network Access Control via firewalld
&lt;/h2&gt;&lt;p&gt;The server-side firewall must explicitly permit traffic on the FTP control port and the defined passive port range to ensure connectivity.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Allow FTP service and passive port range&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo firewall-cmd --permanent --add-service&lt;span style="color:#f92672"&gt;=&lt;/span&gt;ftp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo firewall-cmd --permanent --add-port&lt;span style="color:#f92672"&gt;=&lt;/span&gt;50001-50010/tcp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo firewall-cmd --reload
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="4-creating-a-verification-user-and-confirming-isolation"&gt;4. Creating a Verification User and Confirming Isolation
&lt;/h2&gt;&lt;p&gt;A dedicated test user facilitates the verification of chroot jail restrictions and external connectivity.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Create test user and set password&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo useradd ftpuser
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo passwd ftpuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Successful isolation is confirmed when the user is unable to navigate above their home directory. Verification is performed by checking the current directory path after login to ensure the restricted environment is active.&lt;/p&gt;
&lt;h2 id="operational-notes"&gt;Operational Notes
&lt;/h2&gt;&lt;p&gt;Effective risk management and system optimization require consideration of the following operational factors:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Port Range Design&lt;/b&gt;: The defined range of 10 ports (50001-50010) is intended for environments with limited simultaneous connections. High-traffic servers must expand this range to accommodate the expected connection volume.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;SELinux Considerations&lt;/b&gt;: ⚠️ When SELinux is set to Enforcing mode, home directory access may be restricted. The &lt;code&gt;ftp_home_dir&lt;/code&gt; boolean must be enabled using &lt;code&gt;setsebool -P ftp_home_dir on&lt;/code&gt; to allow proper functionality.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Lack of Encryption&lt;/b&gt;: This configuration utilizes standard FTP, which transmits data in plain text. For production environments handling sensitive data, upgrading to FTPS (FTP over TLS) by enabling &lt;code&gt;ssl_enable=YES&lt;/code&gt; is a security requirement.&lt;/p&gt;</description></item></channel></rss>