denyhosts/README.md

92 lines
2.8 KiB
Markdown
Raw Normal View History

2019-09-24 08:53:00 +08:00
# denyhosts
2022-07-08 09:16:58 +08:00
ssh防止暴力破解,适用Debian 8、9、11 Centos 7
支持钉钉告警和邮件告警
支持第三方QQ邮箱告警
支持一次运行检测、后台运行检测
```
2022-10-22 18:41:00 +08:00
Debian系统请安装libcurl、iptables-devel、libclamav-devel
apt install libclamav-dev libip4tc-dev libcurl4-openssl-dev #(或者libcurl4-gnutls-dev)
freshclam # 更新病毒库(必要)
```
```
2022-10-22 18:41:00 +08:00
Centos 7系统请安装libcurl、iptables-devel、libclamav-devel
yum install clamav clamav-update clamav-lib
yum install iptables-devel libcurl-devel
2022-10-22 18:41:00 +08:00
freshclam # 更新病毒库(必要)
```
2017-11-25 20:14:11 +08:00
2022-07-08 09:16:58 +08:00
```
2019-10-22 23:08:05 +08:00
cd /root
2022-07-08 09:16:58 +08:00
git clone https://git.aixiao.me/aixiao/denyhosts
2019-10-22 23:11:56 +08:00
cd denyhosts
make clean; make
2019-10-22 23:09:45 +08:00
chmod a+x /root/denyhosts/denyhosts.sh
2021-07-11 10:10:55 +08:00
2019-10-22 23:09:45 +08:00
crontab 定时任务,像这样.
0 22 * * * /root/denyhosts/denyhosts.sh
2022-10-22 18:41:00 +08:00
示列:
./rhost -d -r / --exclude-dir="^/sys|^/dev|^/proc|^/opt/infected|^/root|^/home" --move=/opt/infected --max-filesize 1024M -l #后台运行并扫描病毒
./rhost # 只处理非法攻击
2022-07-08 09:16:58 +08:00
```
2019-09-24 08:53:00 +08:00
2022-06-26 19:49:00 +08:00
2022-07-08 09:16:58 +08:00
```
2022-08-06 11:48:21 +08:00
Debian系统使用libiptc库需要nftables切换到iptables
2022-07-08 09:16:58 +08:00
Switching to the legacy version:(切换到 iptables)
2022-06-26 19:49:00 +08:00
2022-07-08 09:16:58 +08:00
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
update-alternatives --set arptables /usr/sbin/arptables-legacy
update-alternatives --set ebtables /usr/sbin/ebtables-legacy
```
```
配置文件
global {
2022-10-22 18:41:00 +08:00
DAEMON = "off"; // on开启后台运行off不开启
TIME = "10"; // 睡眠时间
2022-07-08 09:16:58 +08:00
2022-10-22 18:41:00 +08:00
CLAMAV = 1; // clamav 是否扫描病毒
CLAMAV_TIME = "1726"; // clamav 扫描时间(小时分钟,默认每天运行)
2022-07-08 09:16:58 +08:00
2022-10-22 18:41:00 +08:00
PUBLIC_IP = "http://inet-ip.info"; // 获取公网IP
2022-07-08 09:16:58 +08:00
2022-10-22 18:41:00 +08:00
IPV4_RESTRICTION = 1; // 是否启用IP白名单
IPV4_WHITE_LIST = "1.1.1.1 "; // IP白名单
2022-10-14 10:46:34 +08:00
2022-10-22 18:41:00 +08:00
REGION = 1; // 是否启用地域白名单
REGION_LIST = "河南 郑州"; // 地域列表
2022-10-14 10:46:34 +08:00
2022-10-22 18:41:00 +08:00
IS_BLOCKED = 1; // 是否封禁攻击IP
REFUSE_NUMBER = 3; // 拒绝攻击次数
2022-10-22 18:41:00 +08:00
IS_MAIL = 0; // 开启邮件告警
2022-10-22 18:41:00 +08:00
IS_DING_WEBHOOK = 0; // 开启叮叮告警
PHONE = "15565979082"; // @的人手机号
2022-07-08 09:16:58 +08:00
DING_WEBHOOK = "https://oapi.dingtalk.com/robot/send?access_token=7f069c672cb878987aa6772cca336740eece4ce36bde12b51b45e9f440e0565a"; // 钉钉WEBHOOK
2022-10-22 18:41:00 +08:00
IS_QQMAIL = 0; // 开启QQ邮箱告警(默认使用gomailhttps://git.aixiao.me/aixiao/gomail.git)
RECV_MAIL = "1605227279@qq.com"; // 接收者QQ
2022-07-08 09:16:58 +08:00
}
2022-10-14 10:46:34 +08:00
2022-10-22 18:41:00 +08:00
2022-07-13 11:27:22 +08:00
```