Skip to content

Instantly share code, notes, and snippets.

@wrzlbrmft
Created March 29, 2016 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrzlbrmft/589dfa49942f7bd8bec9 to your computer and use it in GitHub Desktop.
Save wrzlbrmft/589dfa49942f7bd8bec9 to your computer and use it in GitHub Desktop.
List IPs/encounters or hostnames of invalid/accepted logins to sshd.
### invalid logins
# journalctl (last 7 days)
journalctl --since -7d | grep 'sshd.*Invalid' | awk '{ print $10 }' | sort | uniq -c
journalctl --since -7d | grep 'sshd.*Invalid' | awk '{ print $10 }' | sort | uniq | xargs -n1 dig +short -x
# /var/log/auth.log
cat /var/log/auth.log | grep 'sshd.*Invalid' | awk '{ print $10 }' | sort | uniq -c
cat /var/log/auth.log | grep 'sshd.*Invalid' | awk '{ print $10 }' | sort | uniq | xargs -n1 dig +short -x
### accepted logins
# journalctl (last 7 days)
journalctl --since -7d | grep 'sshd.*Accepted' | awk '{ print $11 }' | sort | uniq -c
journalctl --since -7d | grep 'sshd.*Accepted' | awk '{ print $11 }' | sort | uniq | xargs -n1 dig +short -x
# /var/log/auth.log
cat /var/log/auth.log | grep 'sshd.*Accepted' | awk '{ print $11 }' | sort | uniq -c
cat /var/log/auth.log | grep 'sshd.*Accepted' | awk '{ print $11 }' | sort | uniq | xargs -n1 dig +short -x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment