| Protect your SSH with fail2ban |
|
|
|
| News - Ubuntu / Linux / Unix |
| Written by Mark Veenstra |
| Saturday, 04 December 2010 14:29 |
|
If your running a Linux/Unix server and for some reason you have your SSH open to the world, you might want to consider to protect your SSH by getting attacked and cracked. I searched the Internet for some solutions and to my opinion the best and easiest way to go is using "fail2ban". Nice thing about fail2ban is that it can also help you with auto blacklisting FTP and other applications. Here a little howto:
[ssh-iptables] enabled = true filter = sshd action = iptables[name=SSH, port=ssh, protocol=tcp] sendmail-whois[name=SSH, dest=your@email.com, sender=fail2ban@mail.com] logpath = /var/log/secure maxretry = 5 [root@home ~]# /etc/init.d/fail2ban restart
For example I have tried to login 5 times from a PC to the server. After 5 fails, fail2ban blocked my IP. You can see this in logfile: /var/log/fail2ban.log
2010-12-04 16:54:34,655 fail2ban.actions: WARNING [ssh-iptables] Ban 192.168.1.202
If this is an IP address you would like to move from the blacklist, please follow the next steps:
[root@home ~]# iptables -L -n
Chain fail2ban-SSH (1 references) target prot opt source destination DROP all -- 192.168.1.202 0.0.0.0/0 RETURN all -- 0.0.0.0/0 0.0.0.0/0 iptables -D fail2ban-SSH -s 192.168.1.202 -j DROP
|
| Last Updated on Saturday, 04 December 2010 15:08 |




Click here to hear this article