advertisement logo

 

This is the quickest way to limit the number of connection to your SSH server with iptables.

sudo /sbin/iptables -A INPUT -p tcp --syn --dport 22 -m connlimit --connlimit-above 5 -j REJECT

This will only allow up to 5 concurrent connections to the SSH server, subsequent connections will be rejected by iptables, thus this can thwarts Brute-force attempts to your server.

More Articles About Securing SSH Server


Share this post

Tags: , , , , , , ,

Keep updated with the latest posts, be a part of over 1,000 subscribers! : email iconSubscribe to your email

3 smashing comments for this post.

  1. Eric Yeoh Said:

    You can also use tcpwrapper to control the connection to the service.

  2. Shyne Said:

    Not for Archlinux users: http://www.archlinux.org/news/dropping-tcp_wrappers-support/

  3. manojkumar Said:

    While running the above command am getting the following error

    /sbin/iptables -A INPUT -p tcp –syn –dport 22 -m connlimit –connlimit-above 8 -j REJECT
    iptables: Unknown error 18446744073709551615

    Am using Amazon AWS EC2 virtual machine, please let me know how i can fix this issue

Leave a Comment

About Author

Mohammad Hafiz (mypapit)

Blogger
Alor Setar, Kedah, MALAYSIA


I work with a local university in Malaysia. I code for fun and I support Free and Open Source Software.


Visit