VSFTP in Ubuntu: Log Management Guide
To enable and customize logging for VSFTP (Very Secure FTP Daemon) on Ubuntu, modify its main configuration file (/etc/vsftpd.conf). Key directives include:
xferlog_enable=YES: Enables transfer logging (records upload/download activities).xferlog_file=/var/log/vsftpd.log: Specifies the path for transfer logs (default location).xferlog_std_format=YES: Uses the standard WU-FTP log format (compatible with tools like ftpwho).syslog_enable=YES: Enables system logging (sends logs to syslog).syslog_facility=local0: Tags VSFTP logs with local0 facility for easy filtering.syslog_ident=vsftpd: Identifies VSFTP logs in syslog with the “vsftpd” label.After editing, save the file and restart the VSFTP service to apply changes:
sudo systemctl restart vsftpd
These settings ensure comprehensive logging of FTP activities and system events.
You can view VSFTP logs using multiple methods:
tail, less, or cat to read the transfer log (/var/log/vsftpd.log) or system logs:sudo tail -f /var/log/vsftpd.log # Real-time monitoring
sudo less /var/log/vsftpd.log # Paginated view
sudo grep vsftpd /var/log/syslog # Filter system logs for VSFTP entries
journalctl to query VSFTP service logs with filters:sudo journalctl -u vsftpd.service # All VSFTP logs
sudo journalctl -u vsftpd.service -f # Real-time updates
sudo journalctl -u vsftpd.service --since="2025-11-01" --until="2025-11-10" # Time-range logs
These commands help troubleshoot issues (e.g., failed logins, connection errors) by providing real-time or historical log data.
To prevent log files from growing indefinitely, configure log rotation using Ubuntu’s logrotate tool. The default configuration file for VSFTP is /etc/logrotate.d/vsftpd—edit it to include:
/var/log/vsftpd.log {
daily # Rotate logs daily
missingok # Skip if log file is missing
rotate 7 # Keep 7 days of rotated logs
compress # Compress old logs (gzip)
notifempty # Don’t rotate empty logs
create 640 root adm # Set permissions for new log file
}
This setup retains logs for a week, compresses old logs to save disk space, and ensures the new log file has proper ownership/permissions. Test the configuration with:
sudo logrotate -vf /etc/logrotate.d/vsftpd # Force a rotation for testing
Log rotation helps maintain disk health and makes log management more efficient.
For more granular control (e.g., separating VSFTP logs from other system logs), integrate VSFTP with rsyslog.
/etc/rsyslog.d/50-default.conf to direct local0 logs (used by VSFTP) to a dedicated file:local0.* /var/log/vsftpd.log
rsyslog and vsftpd:sudo systemctl restart rsyslog
sudo systemctl restart vsftpd
This setup isolates VSFTP logs in /var/log/vsftpd.log, making it easier to analyze FTP-specific activities without sifting through general system logs.
Analyze VSFTP logs to monitor usage, detect anomalies, and troubleshoot issues:
grep "vsftpd.*session opened" /var/log/vsftpd.log | wc -lgrep "vsftpd.*authentication failed" /var/log/vsftpd.logawk '{print $5}' /var/log/vsftpd.log | cut -d: -f1 | sort | uniq -cgrep, awk, or sed for simple filtering.By following these steps, you can effectively manage VSFTP logs on Ubuntu—ensuring secure, organized, and actionable log data for your FTP server.