synchronization
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
2025-08-25 15:57:40 +08:00
commit cee91802b3
106 changed files with 9124 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
> 本文作者:丁辉
# 系统安全策略配置
## 限制 Linux 最大限制远程登录次数
### 方法一
1. 编辑 SSH 服务配置文件
```bash
vi /etc/ssh/sshd_config
```
修改如下内容
```bash
# 设置每个IP地址的最大登录尝试次数
MaxAuthTries 3
# 设置封锁的时间单位为秒这里设置为300秒即5分钟
LoginGraceTime 300
```
2. 重载配置
```bash
systemctl reload sshd
```
### 方法二
1. 安装 fail2ban
```bash
yum install epel-release -y
yum install fail2ban -y
```
2. 配置 fail2ban
```bash
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
```
编辑`jail.local`文件,找到并更改以下参数
```bash
# 设置ban的时间以秒为单位默认值为600秒即10分钟
bantime = 600
# 允许尝试登录的最大次数
maxretry = 5
# 将这个值设置为yesfail2ban将禁止任何主机的IP如果该主机的IP多次失败这对于保护你的系统非常有用。
# 但要谨慎使用,以防止合法用户因错误登录被阻止。
banaction = iptables-multiport
```
3. 启动 fail2ban 服务
```bash
systemctl start fail2ban
systemctl enable fail2ban
```
4. 检查fail2ban状态
```bash
fail2ban-client status
```