Why
From https://github.com/ossec/ossec-hids:OSSEC is a full platform to monitor and control your systems. It mixes together all the aspects of HIDS (host-based intrusion detection), log monitoring and SIM/SIEM together in a simple, powerful and open source solution.OSSEC provides comprehensive host intrusion detection, log analysis, file integrity monitoring, rootkit detection, and real-time alerting.
Goals
- OSSEC-HIDS installed and monitoring your server
- Active intrusion detection and alerting
How It Works
OSSEC monitors your system by:- Log Analysis - Analyzing log files for suspicious activity
- File Integrity Monitoring - Detecting unauthorized file changes
- Rootkit Detection - Scanning for rootkits and malware
- Real-time Alerting - Notifying you of security events
- Active Response - Automatically responding to threats
References
Installation and Setup
Download OSSEC
Download the latest OSSEC source:
Check the OSSEC GitHub releases page for the latest version number and update the commands accordingly.
Run the installer
Execute the installation script:The installer will prompt you with questions about how to configure OSSEC. Answer according to your needs:
- Installation type:
local(for a standalone server) - Email notification: Enter your email address
- SMTP server: Enter your SMTP server (e.g., localhost if using local MTA)
- Enable integrity check:
yes - Enable rootkit detection:
yes - Enable active response:
yes(if desired)
For a typical standalone server installation, choose “local” installation type.
Managing OSSEC
Agent Information
View information about the OSSEC agent:By default, the agent ID is
000 for a local installation. You can verify with:Run Integrity/Rootkit Checking
OSSEC automatically runs rootkit checks every 2 hours by default. To trigger a manual check:<AGENT_ID> with your agent ID (typically 000).
Monitoring Alerts
View All Alerts
To monitor all OSSEC alerts in real-time:View Integrity Check Alerts
To see only file integrity monitoring alerts:View Rootkit Check Alerts
To see only rootkit detection alerts:Understanding Alert Levels
OSSEC uses alert levels to classify events:| Level | Description |
|---|---|
| 0-3 | Informational |
| 4-7 | Low priority |
| 8-11 | Medium priority |
| 12-15 | High priority |
| 16+ | Critical (requires immediate attention) |
Configuration
OSSEC’s main configuration file is/var/ossec/etc/ossec.conf.
Common configuration tasks:
Email Notifications
Ensure email alerting is configured in/var/ossec/etc/ossec.conf:
File Integrity Monitoring
Add directories to monitor in/var/ossec/etc/ossec.conf:
Log Monitoring
Specify which logs to monitor:Active Response
OSSEC can automatically respond to threats. Common active responses include:- Blocking IP addresses after multiple failed login attempts
- Disabling user accounts showing suspicious activity
- Executing custom scripts in response to specific events
/var/ossec/etc/ossec.conf under the <active-response> section.
Useful Commands
Log Files
Important OSSEC log files:| File | Description |
|---|---|
/var/ossec/logs/alerts/alerts.log | All alerts |
/var/ossec/logs/ossec.log | OSSEC service log |
/var/ossec/logs/archives/archives.log | Archived events |
Regular Maintenance
Review alerts daily
Check OSSEC alerts regularly to identify and respond to security events promptly.
Integration with Other Tools
OSSEC works well alongside:- Fail2ban - For automated IP blocking
- AIDE - For additional file integrity monitoring
- logwatch - For complementary log analysis
- Firewall - To act on OSSEC active response triggers