Defensive
Intermediate
Free
Real-time SSH authentication event monitoring from systemd journal
Real-time SSH authentication event monitoring from systemd journal
Linux CLI / Log Analysis
Command
journalctl -u ssh.service --since "1 hour ago" --no-pager | grep -E "(Accepted|Failed|Invalid)" | awk '{print $1, $2, $3, $9, $11}'
Syntax
journalctl -u <service> --since "<time>" | grep <pattern>
Use case
Real-time monitoring during an active incident to track authentication events and identify lateral movement via SSH.
Explanation
Systemd journal-based SSH monitoring: • -u ssh.service → Filter to SSH unit • --since "1 hour ago" → Limit time range • --no-pager → Non-interactive output • grep filters Accepted/Failed/Invalid events • awk extracts timestamp, username, and source IP Useful for systemd-based distros (Ubuntu 20+, Fedora, RHEL 8+)
Example output
May 08 14:23:01 Accepted publickey jdoe 192.168.1.50
May 08 14:25:33 Failed password root 203.0.113.1
May 08 14:25:34 Invalid user admin 203.0.113.1
More examples
Primary example
journalctl -u ssh.service --since "1 hour ago" --no-pager | grep -E "(Accepted|Failed|Invalid)" | awk '{print $1, $2, $3, $9, $11}'
Real-time monitoring during an active incident to track authentication events and identify lateral movement via SSH.
linux
journalctl
systemd
ssh
log-analysis
monitoring
Related
Defensive
Beginner
Free
Identify top IPs generating failed SSH login attempts from auth log
Identify top IPs generating failed SSH login attempts from auth log
grep "Failed password" /var/log/auth.log | awk '{print $11}' | sort | uniq -c | sort -rn | head -20
log-analysis
ssh
brute-force
auth
detection
Linux CLI / Log Analysis
Open