Debian attack blocking

From Playful Exploration
Revision as of 08:21, 4 January 2016 by Peter (talk | contribs) (Created page with "== Spotting Attacks == From ssh run: tail /var/log/auth.log Look for repeating errors like these from ip 218.25.208.90: Jan 4 02:55:09 vps58963 sshd[26586]: Disconnecting:...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Spotting Attacks

From ssh run:

tail /var/log/auth.log

Look for repeating errors like these from ip 218.25.208.90:

Jan  4 02:55:09 vps58963 sshd[26586]: Disconnecting: Too many authentication failures for root from 218.25.208.90 port 29523 ssh2 [preauth]
Jan  4 02:55:09 vps58963 sshd[26586]: PAM 5 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.25.208.90  user=root
Jan  4 02:55:09 vps58963 sshd[26586]: PAM service(sshd) ignoring max retries; 6 > 3
Jan  4 02:55:13 vps58963 sshd[26588]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.25.208.90  user=root
Jan  4 02:55:15 vps58963 sshd[26588]: Failed password for root from 218.25.208.90 port 54063 ssh2
Jan  4 02:55:18 vps58963 sshd[26588]: Failed password for root from 218.25.208.90 port 54063 ssh2
Jan  4 02:55:21 vps58963 sshd[26588]: Failed password for root from 218.25.208.90 port 54063 ssh2
Jan  4 02:55:24 vps58963 sshd[26588]: Failed password for root from 218.25.208.90 port 54063 ssh2
Jan  4 02:55:28 vps58963 sshd[26588]: Failed password for root from 218.25.208.90 port 54063 ssh2
Jan  4 02:55:30 vps58963 sshd[26588]: Failed password for root from 218.25.208.90 port 54063 ssh2
Jan  4 02:55:30 vps58963 sshd[26588]: Disconnecting: Too many authentication failures for root from 218.25.208.90 port 54063 ssh2 [preauth]

Now make sure iptables-persistent is installed, add an ip blocking rule to the iptables and save the rules:

apt-get install iptables-persistent
iptables -A INPUT -s 218.25.208.90 -j DROP
invoke-rc.d netfilter-persistent save

Verify that the auth attachs stopped:

tail /var/log/auth.log

The ip blocking rule will survive a reboot.