stop brute force ssh attacks fast

my server is being hit by an ever increas­ing number of brute force attacks via ssh (at least 20 a day…that might not seem like a lot for some of you but it’s plenty for my wee machine that’s con­nec­ted with a domestic adsl line)…check /var/log/secure and /var/log/messages for connect attempts.

the best way to deal with this? well obvi­ously don’t allow root to login over ssh, allow con­nec­tions using ssh2 only and of course use strong pass­words. you could change the default port from 22 to some­thing else too. there are other, more restrict­ive, methods but i won’t go into them here.

my favoured solu­tion? denyhosts. been running it for 5 years or so…it mon­it­ors your logs and blocks ip addresses based on rules that you can tweak to suit your needs. it can also sync your hosts.deny file with a list of known attack­ers thus not even giving them the chance to connect. genius. on a debian-based system (i’m running debian 5) it can be installed with apt-get install denyhosts it can then be con­figured using your favour­ite editor joe /etc/denyhosts.conf see the denyhosts faq for options. after that it basic­ally takes care of itself…you can, however, set it to email you every time a new host is blocked…set this up and watch the ip addresses roll in…

Post to Twitter

1 Response to “stop brute force ssh attacks fast”


Comments are currently closed.

Bear