How to prevent illegal users from probing logins in Linux

Source: Internet
Author: User
Tags iptables

Linux's service hosts are exposed to the Internet and are often harassed by illegal users. such as weak password scan, exploratory login;

All this poses a threat to Linux hosts. The following script will shut out the illegal user.

Principle: Get an attempt to log on to the Linux host user's IP, cut the number of failures more than 10, it is considered that such IP for the illegal user login, and then append their IP to the Iptables rule to filter, so that it can not communicate with the Linux host, the system every 10 minutes to perform.

#/bin/bash
rm-f/data/ip.txt 2>/dev/null
/sbin/iptables-f cat/var/log/secure|awk
'/Failed/{print $ ( NF-3)} ' |sort|uniq-c|awk ' {print $1,$2} ' >/data/ip.txt for
i in ' Cat/data/ip.txt|awk ' {if ($1>=10) {print $}} ' '
do
/sbin/iptables-i input-p all-s ${i}-j drop;sleep 1 done crontab-e */10 * * * *
/data/ip.sh & Gt /dev/null 2>&1

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.