LINUX系统拦截ssh:notty暴力登陆

2026/5/18 20:32:13      点击:

下载附件的脚本文件放到/opt/目录下,然后设置开启启动服务形式,结合IPTABLES可以实现自动封杀扫描爆破行为:

vi /etc/systemd/system/block-ssh-attack.service


[Unit]
Description=Block SSH brute force attacks
After=network.target iptables.service
Wants=network.target

[Service]
Type=simple
ExecStart=/opt/block-ssh-notty.sh
Restart=always
RestartSec=10
Nice=10

[Install]
WantedBy=multi-user.target

# 设置可以执行的文件权限,设置开机启动服务
chmod +x /opt/block-ssh-notty.sh
systemctl daemon-reload
systemctl enable block-ssh-attack.service
systemctl start block-ssh-attack.service