<p>First of all I love a concept called knockd. Since you are ok using an alternate port you may be ok with this unconventional approach. But what you describe sounds very similar to a service I have used in the past. I don&#39;t remember the exact name, but I would search for &quot;harden ssh&quot;. It watches constantly immediately blocking repeat failures, which is much better than waiting 24 hours.</p>

<p><blockquote type="cite">On Dec 23, 2010 9:41 AM, &quot;Van Loggins&quot; &lt;<a href="mailto:vanloggins@gmail.com">vanloggins@gmail.com</a>&gt; wrote:<br><br>I have a Redhat Enterprise linux 5.5 server that is getting over 600 failed ssh login attempts a day.<br>
<br>I&#39;m wanting to lock down the server to protect it but need to keep ssh running.<br><br>I&#39;ve changed my ssh config and went to a higher non standard port which should help but I also want to run a cron job every 24 hours or so that scans for failed ssh login attempts and blocks the IP<br>

<br>I worked on something similar a few years ago on a Centos 3 box and was hoping to get it working again.<br><br>here is the original shell script code<br><br>code begins here:<br><br>#!/bin/bash<br># check for hack attempts and email alerts if seen<br>

searchdate=`date +&#39;%b %e&#39;`<br>searchtime=`date +&#39;%r&#39;`<br>tail -n 100 /var/log/secure &gt; /tmp/output.txt<br>grep &quot;Failed password&quot; /tmp/output.txt &gt; /tmp/faillogin<br>if [ $? = 0 ]<br>        then awk &#39;{print $11}&#39; /tmp/faillogin &gt; /tmp/awkip.txt<br>

        for i in `cat /tmp/awkip.txt`<br>        do<br>                iptables -A INPUT -s $i/32 -j DROP<br>        done<br>        mail <a href="mailto:someone@somewhere.com" target="_blank">someone@somewhere.com</a> -s &quot;Failed login via SSH on<br>

$searchdate at $searchtime&quot; &lt; /tmp/faillogin<br>fi<br><br>End of Code<br><br><br>for some reason it&#39;s erroring out on the do command so it never gets to the iptables command.<br><br>any suggestions, or a better method to do this?<br>

<br><br>
<br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></p>