Try: sudo grep 'Failed password' /var/log/auth.log | awk '{print $11}' | sort | uniq -c | sort -rn | head -5
Info: This command searches /var/log/auth.log for failed SSH authentication attempts, extracts the source IP address with awk, counts occurrences with uniq -c, and sorts the results to show the most frequent offending IP addresses.
Examples:
- $
sudo journalctl -u ssh | grep -i failed | wc -l# Count SSH authentication failures - $
sudo lastb | head# View recent failed login attempts - $
sudo fail2ban-client status sshd# Check currently banned SSH IP addresses
Note: Repeated failed SSH logins can indicate brute-force activity, but failed attempts alone do not prove that someone successfully compromised the server. On systems using systemd-journald without traditional auth logs, use journalctl -u ssh to inspect SSH authentication events. Consider fail2ban to automatically block repeated brute-force attempts.
Leave a Reply