How sshlog/agent works
Main Components
• Daemon Process (core service):
• Located primarily in the “daemon” directory and composed of several logical modules:
▸ CLI Interface (daemon/cli): Handles direct user commands.
▸ Communication Layer (daemon/comms): Manages messaging between components (e.g., MQ clients/servers, event serialization).
▸ Event Handling (daemon/events): Processes and formats SSH events using an event bus.
▸ Plug-in Architecture (daemon/plugins): Divided into actions (e.g., sending emails, triggering syslog, etc.) and filters. This layer enables extensibility.
▸ Trackers (daemon/trackers): Likely used for tracking sessions and their states.
• libsshlog Library:
• Found in “libsshlog”; written in C++ (with associated Python bindings available in libsshlog/bindings/python). Contains components such as:
▸ eBPF Integration (libsshlog/bpf): Contains sources, headers, and scripts related to eBPF probes for SSH session monitoring.
▸ Event Serialization and SSH tracing (libsshlog/event_serializer.cpp, sshlog.cpp, and sshtrace_wrapper.cpp): These components are central in capturing SSH events and converting them into a format that the daemon processes.
• Packaging and Distribution:
• The “package” and “distros” directories: Provide build scripts and packaging configuration for generating OS-specific installable packages (DEB, RPM, etc.) and Docker images.
• Utilities and Build/Configuration Management:
• CMake build scripts (CMakeLists.txt and cmake/ subdirectory) and docker-related files (Dockerfile, .dockerignore) indicate the use of standard build and deployment pipelines.
• External Integration Points:
• The configuration files (e.g., from daemon/config_samples) allow administrators to customize behaviors like sending Slack notifications or directing logs to syslog.
• External systems such as Slack (for messaging), syslog servers, and statsd (for metrics) are part of the broader ecosystem.
Relationships and Interactions
• “Event Bus” in the events submodule, which receives data from eBPF probes (from libsshlog) and then disseminates events to the plugins.
• “libsshlog” with the Daemon – indicate that it provides low-level SSH session and event data (via eBPF probes and event serializers) that are consumed by the Daemon.
• External integrations as separate nodes:
• Slack, Syslog, and Statsd can be illustrated as “external services” that receive notifications or logs via dedicated action plugins.
• Packaging & deployment:
• A section for “Deployment” showing how distribution packages (Debian/RedHat installers) and Docker deployments feed into the overall production environment.
Architectural Patterns and Design Principles
• Modular Design and Separation of Concerns:
• Separate the functionality into distinct components (CLI, communications, event processing, plugins).
• Plug-in Architecture:
• That custom Python plugins extend core functionalities (e.g., filtering, action handling).
• Inter-process Communication:
• Dual Language Integration:
• Coexistence of C++ (for performance and low-level interaction with eBPF) and Python (for easier scripting and extensibility).
Relevant Technologies and Tools
• eBPF (for monitoring SSH sessions)
• CMake (as the build system)
• Docker (for containerized deployments)
• Packaging tools (for building DEB, RPM packages)
• External APIs/integrations (Slack, syslog, statsd)
Final Assembly
• SSH session initiation (via OpenSSH) leading to eBPF probes capturing data.
• How libsshlog processes these events and passes them to the daemon’s event bus.
• That the daemon distributes events to plugins (action and filter plugins) and exposes a control interface (CLI).
• Incorporate side components such as configuration management and packaging infrastructure to complete the architecture overview.