Last active
August 29, 2015 14:11
-
-
Save serverwentdown/0295cf37cd9fee4a1b3f to your computer and use it in GitHub Desktop.
List all failed SSH attempts fancier.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [[ $('uname') == 'Darwin' ]]; then | |
echo "Last 3 failed attempts: " | |
ssh-failed-attempts.sh | tac | head -n 3 | sed 's/^/ /' | |
fi | |
echo "Last 3 logins: " | |
last | head -n 3 | sed 's/^/ /' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cat /var/log/auth.log | grep 'sshd.*Invalid' | sed "s/$(hostname).*d\ user\ /\t/" | sed "s/from/\t/" | awk '{ printf "%-22s%-17s%s\n", $4, $5, " " $1 " " $2 " " $3}' | |
# if using Fedora/Centos/RHEL replace `/var/log/auth.log` with `/var/log/secure` (thanks @jellyjellyrobot) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
different for Centos/RHE/Fedora
cat /var/log/secure | grep 'sshd._Invalid' | sed "s/$(hostname)._d\ user\ /\t/" | sed "s/from/\t/"
http://www.unixmen.com/how-to-check-ssh-logs/