1
Use IPTABLES
The command is as follows: iptables-a input-p tcp-s 192.168.1.1-j ACCEPT allows access to 192.168.1.1 (domain name can also be used)
Iptables-a input-p tcp -- dport 22-j DROP
2
Use the files under/etc/hosts. *
/Etc/hosts. allow and/etc/hosts. deny files
Add a rule in/etc/hosts. allow.
Vim hosts. allow
#
Sshd: 192.168.1.1
#
Vim hosts. deny
#
Sshd: all
#
The above means that only 192.168.1.1 is allowed
Iptables-a input-p tcp-m tcp -- dport 22-m state -- state NEW-m recent -- update -- seconds 60 -- hitcount 2 -- name SSH -- rsource-j DROP
Iptables-a input-P tcp-m tcp -- dport 22-m state -- state NEW-m recent -- set -- name SSH -- rsource-j ACCEPT
The above means that after two wrong SSH passwords are entered, SSH will not be accessible within 60 seconds and an SSH file will be generated in the/proc/net/ipt_recent/directory. record your IP address. of course, the time can be changed.
From: linghunhack Space