Show numbers of failed login attempts

From NAT, 6 Years ago, written in Bash, viewed 589 times.
URL https://code.nat.moe/view/8d998d97 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2. _logs="$(ls /var/log/auth*)"
  3.  
  4. function show {        [[ -z $(echo $log | grep gz) ]] && cat $log || zcat $log              
  5. }
  6.  
  7. count=0
  8. total=0
  9.  
  10. for log in $_logs
  11. do
  12.         let count=count+$(show | grep sshd.\*Failed | wc -l)
  13.         let total=total+$(show | wc -l)
  14. done
  15.  
  16. echo "There are total $total login attempts in logs, and $count of them are failed."

Reply to "Show numbers of failed login attempts"

Here you can reply to the paste above

captcha