Skip to content

Instantly share code, notes, and snippets.

@serverwentdown
Last active August 29, 2015 14:11
Show Gist options
  • Save serverwentdown/0295cf37cd9fee4a1b3f to your computer and use it in GitHub Desktop.
Save serverwentdown/0295cf37cd9fee4a1b3f to your computer and use it in GitHub Desktop.
List all failed SSH attempts fancier.
#!/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/^/ /'
#!/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)
@jellyjellyrobot
Copy link

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/

@serverwentdown
Copy link
Author

yep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment