Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A script for ssh

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

I can't write a lot for the first time, and many of them are wrong. The following is the code I wrote for your reference:

#! / bin/bash

Date_b= `date "+% m%d%H" `

Date_c= `date-d "1 day ago" +% m% d% H`

# ip= `cat / etc/network/interfaces | grep address | awk'{print $2}'| grep-v-E "^ 192 | ^ 127" `

#

For c in `cat / etc/network/interfaces | grep address | awk'{print $2}'| grep-v-E "^ 192 | ^ 127" `

Do

/ bin/netstat-na | grep "$print 22" | awk'{print $5}'| awk-F ":"'{print $1}'| sort | uniq-c | sort-n-r > > iptabsh.txt

For i in `awk'$1 > 5 {print $2} 'iptabsh.txt`

Do

A = `grep "^ $i$" ipallow.txt | wc-l`

If [$a-eq 0]

Then

Echo "$I" > > sh$date_b.txt

Iptables-I INPUT-s "$I"-p tcp-- dport 22-j DROP

Fi

Done

Done

Rm iptabsh.txt

# # #

If [- f sh$date_c.txt]

Then

For i in `cat sh$date_ c.txt`

Do

Iptables-D INPUT-s "$I"-p tcp-- dport 22-j DROP

Done

Fi

Many of them do not set the absolute path, you can set the absolute path according to your storage location.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report