Automatically checks the ip address used to scan the ssh port, and disables the command for 100 scans.

Source: Internet
Author: User
Tags ssh port
Automatically check the ip address used to scan the ssh port, and automatically disable command 01 for 100 scans #! /Bin/bash02 # sshd, failed03cd/var/bakwww.2cto. com04cat/var/log/secure | grepFailed | awk & amp; #39; {print $13} & amp; #39; | sort | uniq...
Automatically check the ip address used to scan the ssh port, and automatically disable command 01 for 100 scans #! /Bin/bash02 # sshd, failed03cd/var/bak www.2cto.com 04cat/var/log/secure | grep Failed | awk '{print $13}' | sort | uniq-c> loginfailed.txt 05cat/var/log/secure | grep Failed | awk '{print $11}' | sort | uniq-c> loginfailed.txt 06sed-I '/[a-z]/d' loginfailed.txt 07sed-I '/ [A-Z]/d 'loginfailed.txt 08cat loginfailed.txt | awk' {if (length ($2)> 7) print} '| sort-n> abc.txt 09 email-s "198, sshd failed" 41187 6027@qq.com <abc.txt 10cat abc.txt | awk '{if (length ($1)> 2) print} '| awk' {print $2} '> bb.txt 11 # cat abc.txt | awk' {if ($1 ~ /5 | 6 | 7 | 8 | 9/) print} '| awk' {print $2} '> bb.txt 12cat bb.txt | xargs-I {} echo "sshd: {} ">/etc/hosts. deny13rm abc.txt 14rm bb.txt 15rm loginfailed.txt 16cp/var/log/secure/var/logbak/secure 'date + % F-% t' 17>/var/log/secure www.2cto.com

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.