Comprehensive security monitoring and hardening toolkit for Linux servers
Features β’ Quick Start β’ Configuration β’ Contributing
| Feature | Description |
|---|---|
| π System Audit | Comprehensive security scanning |
| π‘οΈ Hardening | Automated security hardening |
| π Reporting | Detailed security reports |
| π User Audit | User and permission analysis |
| π Network Scan | Open port and service detection |
| π Logging | Centralized security logging |
| β‘ Lightweight | Pure shell scripts, no dependencies |
| π Automated | Cron-ready for scheduled monitoring |
| Requirement | Version |
|---|---|
| Linux | Any modern distro |
| Bash | 4.0+ |
| Root Access | Required for full functionality |
- β Ubuntu 20.04 / 22.04
- β Debian 11 / 12
- β CentOS 7 / 8
- β RHEL 8 / 9
- β Fedora 36+
git clone https://github.com/CaputoDavide93/linux-security-monitor.git
cd linux-security-monitorchmod +x security-monitor.sh security-manager.shsudo ./security-monitor.shsudo ./security-manager.shComprehensive security monitoring script that:
- Scans for security vulnerabilities
- Checks file permissions
- Audits user accounts
- Analyzes network configuration
- Generates detailed reports
# Full security scan
sudo ./security-monitor.sh --full
# Quick scan
sudo ./security-monitor.sh --quick
# Generate report
sudo ./security-monitor.sh --report /var/log/security-report.txtInteractive security management tool for:
- Applying security hardening
- Managing firewall rules
- Configuring security policies
- Scheduling automated scans
# Interactive mode
sudo ./security-manager.sh
# Apply hardening profile
sudo ./security-manager.sh --harden basic
# Check compliance
sudo ./security-manager.sh --compliance cis| Variable | Description | Default |
|---|---|---|
LOG_DIR |
Log directory | /var/log/security |
REPORT_DIR |
Report output directory | /var/log/security/reports |
EMAIL_ALERTS |
Email for alerts | - |
SEVERITY_LEVEL |
Min severity to report | medium |
QUIET_MODE |
Suppress output | false |
Create /etc/security-monitor.conf:
# Security Monitor Configuration
LOG_DIR="/var/log/security"
REPORT_DIR="/var/log/security/reports"
EMAIL_ALERTS="security@example.com"
SEVERITY_LEVEL="medium" # low, medium, high, critical
# Scan Options
SCAN_USERS=true
SCAN_NETWORK=true
SCAN_FILESYSTEM=true
SCAN_SERVICES=true
# Hardening Options
DISABLE_ROOT_SSH=true
ENFORCE_STRONG_PASSWORDS=true
ENABLE_FAIL2BAN=true| Check | Description |
|---|---|
| Root Login | SSH root access disabled |
| Empty Passwords | No accounts without passwords |
| Sudo Access | Validate sudoers configuration |
| Failed Logins | Detect brute force attempts |
| Inactive Users | Find dormant accounts |
| Check | Description |
|---|---|
| Open Ports | Identify listening services |
| Firewall Status | Verify firewall is active |
| SSH Config | Secure SSH configuration |
| Network Services | Audit running services |
| Check | Description |
|---|---|
| World Writable | Find insecure permissions |
| SUID/SGID | Locate privilege escalation risks |
| Sensitive Files | Check /etc/passwd, /etc/shadow |
| Mounted Drives | Verify mount options |
| Check | Description |
|---|---|
| Kernel Version | Check for known vulnerabilities |
| Updates | Pending security updates |
| Running Processes | Suspicious process detection |
| Cron Jobs | Audit scheduled tasks |
# Text report
sudo ./security-monitor.sh --report-format text
# JSON report (for automation)
sudo ./security-monitor.sh --report-format json
# HTML report
sudo ./security-monitor.sh --report-format htmlβββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SECURITY AUDIT REPORT
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Generated: 2024-01-12 10:30:00
Hostname: production-server-01
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
[CRITICAL] 2 issues found
[HIGH] 5 issues found
[MEDIUM] 12 issues found
[LOW] 8 issues found
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
CRITICAL FINDINGS:
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Root SSH login is enabled
β 3 accounts have empty passwords
...
# Edit crontab
sudo crontab -e
# Daily security scan at 2 AM
0 2 * * * /opt/linux-security-monitor/security-monitor.sh --full --email
# Weekly full report
0 3 * * 0 /opt/linux-security-monitor/security-monitor.sh --report /var/log/security/weekly-report.txtβ Permission Denied
# Run with sudo
sudo ./security-monitor.sh
# Or fix permissions
chmod +x security-monitor.shβ Command Not Found
Some checks require additional tools:
# Debian/Ubuntu
sudo apt install net-tools procps
# RHEL/CentOS
sudo yum install net-tools procps-ngβ Report Not Generated
# Check log directory permissions
sudo mkdir -p /var/log/security
sudo chmod 755 /var/log/securitySee TEST-GUIDE.txt for testing instructions:
# Run in test mode (no changes)
./security-monitor.sh --dry-run
# Verbose output
./security-monitor.sh --verboseContributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.