Skip to content

Instantly share code, notes, and snippets.

@yatt
Created January 15, 2012 14:26
Show Gist options
  • Select an option

  • Save yatt/1616009 to your computer and use it in GitHub Desktop.

Select an option

Save yatt/1616009 to your computer and use it in GitHub Desktop.
lazy script for blocking against ssh attack
#!/bin/sh
tbl=deny.sqlite3
log=/var/log/auth.log
sqlite3 $tbl 'create table if not exists hosts (ipaddr varchar(255) primary key);'
for addr in $(grep Invalid $log | awk '{print $10}' | sort | uniq)
do
sqlite3 deny.sqlite3 "insert or ignore into hosts values ('$addr')"
done
sqlite3 deny.sqlite3 "select 'sshd: ' || ipaddr from hosts"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment