Lesson 69: Monitoring User Login Attempts

Track failed login attempts from system logs using Python.

log_file = "/var/log/auth.log"
failed_count = 0

with open(log_file) as f:
  for line in f:
    if "Failed password" in line:
      failed_count += 1

print(f"⚠️ Total failed logins: {failed_count}")

This helps detect potential brute-force attacks safely.

Next Lesson →