Re: restrict ssh access



On Mon, 26 Dec 2005 14:34:42 -0800, Xinming He wrote:

> We have one ssh server which receives about 6000 failed attempts to login
> using various usernames everyday from malicious hosts (averaging about
> 1000 attempts from each distinct client IP address). Does anyone know if
> there is a way to restict the number or rate of unsuccessful login
> attempts per client IP address? For example, configure ssh server to
> accept only one ssh connection request per minute from the same client IP
> address. Thanks very much.
>
> Simon(Xinming)


This is something I picked up at some newsgroup not long ago.


#! /bin/sh
#
# This is a deterrent against SSH breakin attempts. Without this, /var/log/
# messages tends to get flooded by traces from such attempts. The last two
# lines of this script prevent such attempts to take place more frequently
# than every 15 seconds. Effectively, a failed SSH login attempt from a given
# IP address results in any further SSH login attempts from that address to
# be summarily dismissed for 15 seconds. The first line in the script just
# that this mechanism is not to be used for our internal network.


iptables -A INPUT -p tcp -i eth0 -s 192.168.0.0/24 --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -i eth0 -m state --state NEW --dport 22 -m recent --update --seconds 15 -j DROP
iptables -A INPUT -p tcp -i eth0 -m state --state NEW --dport 22 -m recent --set -j ACCEPT

.



Relevant Pages

  • Re: NX authentication error
    ... shipped key from server to client. ... ssh -l USER1 server ... when I login via nxclient, after pass steps Connected, download ... nxuser only creates an ssh tunnel. ...
    (Fedora)
  • Re: Blocking attacks from spoofed IP addresses
    ... Some of the ssh attacks are distributed. ... So IMHO public key authentication does not necessarily reduce risks. ... if one is scared about login unwanted attempts on a ssh server ...
    (comp.os.linux.networking)
  • Re: SSH login automation, get stuck at the last step.
    ... The ssh server that I am copying the public key to is not a typical ... The user "root" to login this box can not access the ... puts stderr "EXP username requested and sent " ...
    (comp.lang.tcl)
  • RE: Login Timeout Problems
    ... or just add the client ip in /etc/hosts like: ... Because before letting you to open telnet-ssh or ftp connection Linux do a ReverseDNS lookup. ... Objet: Re: Login Timeout Problems ... I'll try to SSH to another computer and see what happens. ...
    (RedHat)
  • Password less login between client & server, server & client
    ... password less logins on both the ssh client and ssh server. ... Login as the user that is making the connection. ...
    (comp.security.ssh)