Re: SSH and iptables



On Thu, 09 Mar 2006 02:19:20 +0000, Robby Workman wrote:

On 2006-03-08, Steven Jones <sjones@xxxxxxxxxx> wrote:
I am looking for iptables rules to do the following:

When an SSH connection attempt (at the standard port) from a given IP
address fails, no further SSH connections will be accepted from that IP
address for 60 seconds.

If, on the other hand, the connection attempt succeeds, then that IP
address is free to start as many (successful) SSH connections within the
next 60 seconds (and beyond, in fact).

Is this possible? I am aware of numerous iptables rules that can do
something similar. The catch is that they can't tell whether or not a
connection attempt was unsuccessful.


Hmmm... I'm not taking into account the possible cpu overhead related to
doing this, but you can likely work up something the the recent match:
iptables -A INPUT -i <interface> -p tcp --dport 22 -m state --state \
ESTABLISHED -m recent --set --rsource --name SSH_EST -j ACCEPT
iptables -A INPUT -i <interface> -p tcp --dport 22 -m state --state \
NEW -m recent --rcheck --rsource --name SSH_EST -j ACCEPT

Note that this is untested, written from memory, and may not have a chance
of working, even if load concerns are irrelevant - it does, however, give
you something on which to chew...

Hmm... Are these rules able to tell between successful and nonsuccessful
login attempts?



.



Relevant Pages

  • Re: IOSTAT=127
    ... Just the opposite. ... while logged in via ssh connections from other computers. ... and it fails for him. ... allow User C to write to Disk B, and Program D allows User C to write ...
    (comp.lang.fortran)
  • Re: SSH and iptables
    ... Steven Jones wrote: ... address fails, no further SSH connections will be accepted from that IP ... which the authentification fails 3 times within 10 minutes for another ...
    (comp.os.linux.networking)
  • Re: SSH and iptables
    ... When an SSH connection attempt (at the standard port) from a given IP ... address fails, no further SSH connections will be accepted from that IP ... I'm not taking into account the possible cpu overhead related ...
    (comp.os.linux.networking)
  • SSH and iptables
    ... I am looking for iptables rules to do the following: ... When an SSH connection attempt (at the standard port) from a given IP ... address fails, no further SSH connections will be accepted from that IP ...
    (comp.os.linux.networking)