perloader

yum install epel-release

yum install fail2ban

systemctl enable fail2ban

cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
service fail2ban start

通过查看 /var/log/fail2ban.log 文件即可知道有哪些精力过剩的家伙在整天扫描你的 SSH 了。

 

限制SSH登录IP地址

添加允许访问的IP

vi /etc/hosts.allow

sshd:xx.xx.xx.xx
sshd:xx.xx.xx.xx
sshd:xx.xx.xx.xx

禁止其它的所有IP

vi /etc/hosts.deny

sshd: ALL

 

检查登录日志

who /var/log/wtmp

history能看到这个用户历史命令,默认最近的1000条

xyz