36.3 ProFTPD (with MySQL)
Installing ProFTPD
# pkg install proftpd proftpd-mod_sql_mysql# cd /usr/ports/ftp/proftpd/ && make install clean
# cd /usr/ports/databases/proftpd-mod_sql_mysql/ && make install cleanProFTPD Configuration File
ServerName "Test Ftp Server" # FTP server name
ServerType standalone # Standalone mode
DefaultServer on # Set as default server
ServerIdent on "FTP Server ready" # Server identification information
Port 21 # Listening port
Umask 022 # File creation mask
# Timeout settings
TimeoutLogin 300 # Login timeout (seconds)
TimeoutIdle 36000 # Idle timeout (seconds)
TimeoutNoTransfer 36000 # No-transfer timeout (seconds)
# Resource limits
User proftpd # Service running user
Group proftpd # Service running group
RLimitMemory 256M 256M # Memory limit
RLimitOpenFiles 1024 1024 # Open file count limit
PassivePorts 50000 60000 # Passive mode port range
# Log configuration
LogFormat default "%h %l %u %t \"%r\" %s %b" # Default log format
LogFormat auth "%v [%P] %h %t \"%r\" %s" # Authentication log format
SystemLog /var/log/proftpd/proftpd.log # System log path
TransferLog /var/log/proftpd/xfer.log # File transfer log path
ExtendedLog /var/log/proftpd/auth.log AUTH auth # Extended authentication log
# MySQL module loading
LoadModule mod_sql.c
LoadModule mod_sql_mysql.c
LoadModule mod_sql_passwd.c
# Only allow access to respective directories
DefaultRoot ~ # Restrict users to their home directory
# Allow file overwriting
AllowOverwrite on # Allow file overwrite
<Global>
# Database connection
SQLConnectInfo proftpd@localhost proftpd <your_database_password> # Database connection info (user, host, password)
# Password authentication settings
SQLAuthTypes SHA256 # Use SHA256 encrypted authentication
SQLPasswordEngine on # Enable SQL password engine
# User table mapping
SQLUserInfo users username password uid gid homedir shell # Map users table fields
SQLDefaultGID 2000 # Default GID
SQLDefaultUID 2000 # Default UID
RequireValidShell off # Do not require a valid shell
# Authentication order
AuthOrder mod_sql.c
SQLAuthenticate users # Use SQL user table for authentication
# Login statistics
SQLNamedQuery getcount SELECT "CONCAT('Total logins: ', count) FROM users WHERE username='%u'" # Query login count
SQLNamedQuery updatecount UPDATE "count=count+1 WHERE username='%u'" users # Update login count
SQLShowInfo PASS "230" "%{getcount}" # Display login statistics
SQLLog PASS updatecount # Record login statistics
# File operation logging
SQLNamedQuery log_work FREEFORM "INSERT INTO worklog (user_name, file_and_path, bytes, send_time, client_ip, client_name, client_command) VALUES ('%u', '%f', %b, NULLIF('%T', ''), '%a', '%h', '%m')" # File operation log record
SQLLog RETR,STOR,DELE log_work # Log RETR, STOR, DELE operations to the worklog table
</Global>Related File Structure
Creating Users
MySQL Database Setup
Item
Value
Service Operations
Last updated