- first published:
- Feb 14, 2008
- tags:
Brute-force password-guessing attacks on SSH services are common on the Internet today. They are a threat for two reasons:
- A large number of SSH password-guessing attempts can result in a denial of service — by saturating network connections, consuming large amounts of CPU resources (and therefore power), and/or by filling log partitions with all of the failed attempts.
- An attacker might get lucky and successfully guess a username/password combination.
Both of these scenarios are bad. We can substantially reduce, or even eliminate these threats by rate-limiting incoming SSH connections — not globally, but on a per-source-IP basis. On Linux, we can use the RECENT
match facility available in modern versions of iptables
to achieve this.
Here is prettified version of the configuration that is currently running on Kalimdor
; see the comments in-line for an explanation of what each rules does.
⚠ Caution
Before proceeding, check that your kernel version is greater than or equal to 2.6.18. Do not use the RECENT
match implementation included in kernels prior to 2.6.18 as it is faulty; see CAN-2005-2872 and CAN-2005-2873 for details.
|
|
This scheme will likely become wildly impractical as IPv6 takes off; with 128-bits of address-space and a liberal allocation scheme, any intelligent attacker would jump between available addresses within the netblock that they control. When this happens, more sophisticated mechanisms for identifying and dropping packets from whole netblocks will become necessary.