Get the App
SLTechnology News&Howtos  ›  Network Security  › 

A script for ssh

Shulou Source: shulou.com Published: 2022-06-01 07:32:04 10月03日 Update

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.

Tags: Path code location first time reference script Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Xiaomi MariaDB Microsoft NVidia