Skip to content

Instantly share code, notes, and snippets.

@Bambarello
Forked from gfoss/ssh-attempts.txt
Last active December 30, 2018 16:08
Show Gist options
  • Save Bambarello/5e193d0a7374d38f11636cddc744a71f to your computer and use it in GitHub Desktop.
Save Bambarello/5e193d0a7374d38f11636cddc744a71f to your computer and use it in GitHub Desktop.
grep IP addresses from auth logs to see attempted ssh attempts into your box w/ invalid creds {ubuntu}
#search for invalid logon attempts, pull out IP, remove dupes, sort...
$ grep -rhi 'invalid' /var/log/auth.log* | awk '{print $10}' | uniq | sort > ~/ips.txt
#look em up
$ for i in `cat ~/ips.txt`; do @nslookup $i 2>/dev/null | grep Name | tail -n 1 | cut -d " " -f 3; done > ~/who.txt
#search through system journal deamon all failed SSH attempts.
# journalctl _SYSTEMD_UNIT=ssh.service | egrep "Failed|Failure"
# journalctl _SYSTEMD_UNIT=sshd.service | egrep "Failed|Failure" #In RHEL, CentOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment