- Installign vsftpd
This section covers the instalation and initial setup of the vsftpd package using the package manager.
1.1 Package Installation
Install the vsftpd daemon using the yum package manager:
[root@host ~]# yum -y install vsftpd
1.2 Configuration File Location
The main configuration file is located at:
[root@host ~]# vim /etc/vsftpd/vsftpd.conf
1.3 Enabling and Starting the Service
Configure the service to start automatically at boot and start the daemon:
[root@host ~]# systemctl enable vsftpd.service
[root@host ~]# systemctl start vsftpd.service
1.4 Firewall and SELinux Configuration
Configure firewall rules to allow FTP traffic and adjust SELinux settings:
# Add permanent firewall rule for FTP service
[root@host ~]# firewall-cmd --permanent --add-service=ftp
[root@host ~]# firewall-cmd --reload
# Temporarily disable SELinux enforcement
[root@host ~]# setenforce 0
# Permanently disable SELinux by editing configuration
[root@host ~]# vim /etc/sysconfig/selinux
# Change SELINUX=enforcing to SELINUX=disabled
- Accessing the FTP Server
Client-side tools are required to connect to the FTP server.
2.1 Installing FTP Client
Install the lftp client application:
[root@host ~]# yum -y install lftp
2.2 Client Usage
Connect to the FTP server using lftp:
[root@host ~]# lftp 192.168.100.10
Common lftp commands include mirror for directory synchronization, cd for directory navigation, and get for file downloads.
- FTP Server Access Configuration
3.1 Creating a Dedicated User
Create a system user specifically for FTP access:
[root@host ~]# useradd ftpuser
[root@host ~]# touch /home/ftpuser/sample.txt
[root@host ~]# passwd ftpuser
[root@host ~]# usermod -s /sbin/nologin ftpuser
3.2 Connecting to FTP Service
Access the FTP server with user credentials:
[root@host ~]# lftp ftpuser@192.168.100.10
3.3 Key Configuration Directives
Edit the vsftpd.conf file to customize server behavior:
# Anonymous access settings
anonymous_enable=YES # Allow anonymous user access
anon_umask=077 # Set permission mask for anonymous uploads
anon_root=/var/ftp/anonymous # Define anonymous user root directory
anon_max_rate=500000 # Limit anonymous user bandwidth (bytes/sec)
# Local user settings
local_enable=YES # Permit local system users to login
write_enable=YES # Enable write permissions
local_umask=022 # Set default umask for local user uploads
local_max_rate=80000 # Limit local user bandwidth
local_root=/ftproot # Set root directory for local users
# Connection limits
max_clients=500 # Maximum concurrent connections
max_per_ip=2 # Maximum connections per IP address
# Chroot jail configuration
chroot_list_enable=YES # Enable chroot list
chroot_list_file=/etc/vsftpd/chroot_list # Users excluded from jail
chroot_local_user=YES # Apply chroot to all local users
3.4 Accessing FTP from Windows
Windows Explorer and browsers support direct FTP access via URL:
ftp://192.168.100.10
- Sharing YUM Repositories via FTP
FTP servers can distribute yum repository metadata to client systems.
4.1 Server-Side Setup
Create repository directories and mount ISO images:
[root@repo-server ~]# mkdir -p /var/ftp/{rhel8u2,rhel9u1}
[root@repo-server ~]# mount -o loop /dev/sr0 /var/ftp/rhel9u1/
[root@repo-server ~]# echo "mount -o loop /dev/sr0 /var/ftp/rhel9u1/" >> /etc/rc.local
[root@repo-server ~]# chmod +x /etc/rc.d/rc.local
4.2 Client-Side Configuration
Configure yum client to use the FTP repository:
[root@client ~]# cat > /etc/yum/repos.d/rhel9.repo << EOF
[rhel9u1]
name=RHEL 9 Update 1
baseurl=ftp://192.168.100.10/rhel9u1/
gpgcheck=0
enabled=1
EOF
Verify the repository configuration:
[root@client ~]# yum clean all
[root@client ~]# yum repolist