From: Siraaj Khandkar Date: Mon, 2 Nov 2020 10:18:58 +0000 (-0500) Subject: Implement ssh_invalid_attempts_from counter gauge X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=ae23e5e390ca695733c7cb531cce109aee7ad6a5;p=khome.git Implement ssh_invalid_attempts_from counter gauge --- diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index 243f15f..a161d4b 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -569,3 +569,25 @@ motd() { | column -t \ | indent "${indent_unit}" } + +ssh_invalid_attempts_from() { + awk ' + /: Invalid user/ && $5 ~ /^sshd/ { + u=$8 + addr=$10 == "port" ? $9 : $10 + max++ + curr[addr]++ + } + + END { + for (addr in curr) + if ((c = curr[addr]) > 1) + print c, max, addr + } + ' \ + /var/log/auth.log \ + /var/log/auth.log.1 \ + | sort -n -k 1 \ + | bar_gauge -v width=80 -v num=1 -v ch_right=' ' -v ch_left=' ' -v ch_blank=' ' \ + | column -t +}