差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
| it:server:保护 [2022-08-27 15:21] – goldentianya | it:server:保护 [2022-08-29 19:03] (当前版本) – [保护VPS] goldentianya | ||
|---|---|---|---|
| 行 13: | 行 13: | ||
| < | < | ||
| sudo grep " | sudo grep " | ||
| + | </ | ||
| + | |||
| + | 3. 统计以root或者其它用户登录的次数 | ||
| + | < | ||
| + | sudo grep " | ||
| + | sudo grep " | ||
| </ | </ | ||
| 行 21: | 行 27: | ||
| * <color # | * <color # | ||
| * <color # | * <color # | ||
| + | |||
| + | < | ||
| + | // 统计以 root 用户尝试登录到数量 | ||
| + | sudo grep " | ||
| + | // 统计以其它用户试登录到数量 | ||
| + | sudo grep " | ||
| + | </ | ||
| < | < | ||
| PasswordAuthentication no | PasswordAuthentication no | ||
| - | PermitRootLogin | + | PermitRootLogin |
| PubkeyAuthentication yes // 允许公钥登录 | PubkeyAuthentication yes // 允许公钥登录 | ||
| + | RSAAuthentication yes | ||
| + | ChallengeResponseAuthentication no | ||
| + | // | ||
| + | sudo / | ||
| </ | </ | ||
| - | === fail2ban === | + | 将公钥复制到服务器,密码登录一次。验证完公钥登录后,关闭密码登录 <color # |
| + | < | ||
| + | ssh-copy-id -i ~/ | ||
| + | </ | ||
| + | |||
| + | <color # | ||
| + | |||
| + | 使用的密码身份验证PAM(在所有现代系统上)是由ChallengeResponseAuthentication选项处理的,yes默认情况下。质询响应认证指定是否允许质询-响应身份验证(例如,通过 PAM)。默认值为“是”。将它添加到您的sshd_configwith value no,重新启动,它将为您工作: | ||
| + | 这在示例中多次提到sshd_config。 | ||
| + | < | ||
| + | # If you just want the PAM account and session checks to run without | ||
| + | # PAM authentication, | ||
| + | # and ChallengeResponseAuthentication to ' | ||
| + | ChallengeResponseAuthentication no | ||
| + | </ | ||
| + | |||
| + | 如果依然可以密码登录,则是 <color # | ||
| + | |||
| + | ===== fail2ban | ||
| 安装 fail2ban 防止攻击 <color # | 安装 fail2ban 防止攻击 <color # | ||
| + | |||
| + | 检查状态 <color # | ||
| + | 解锁ssh fail2ban-client set sshd unbanip < | ||
| + | 或者更改 / | ||
| + | |||
| + | |||
| + | 添加对nginx 和 wordpress 的保护 mkdir -p / | ||
| + | 然后重启服务 | ||
| + | * service fail2ban restart | ||
| + | * fail2ban-client reload | ||
| + | ++++ jail.local | | ||
| + | < | ||
| + | # 保护Linux,防止远程SSH爆破 | ||
| + | [ssh-iptables] | ||
| + | enabled = true | ||
| + | filter | ||
| + | action | ||
| + | logpath = / | ||
| + | |||
| + | # HTTP 验证防暴力破解 | ||
| + | [nginx-http-auth] | ||
| + | enabled | ||
| + | filter | ||
| + | port = http,https | ||
| + | logpath | ||
| + | |||
| + | # | ||
| + | [nginx-badbots] | ||
| + | enabled | ||
| + | port = http,https | ||
| + | filter | ||
| + | logpath | ||
| + | maxretry = 2 | ||
| + | |||
| + | # | ||
| + | [nginx-nohome] | ||
| + | enabled | ||
| + | port = http,https | ||
| + | filter | ||
| + | logpath | ||
| + | maxretry = 2 | ||
| + | |||
| + | #避免 nginx 被他人用于反向代理 | ||
| + | [nginx-noproxy] | ||
| + | enabled | ||
| + | port = http,https | ||
| + | filter | ||
| + | logpath | ||
| + | maxretry = 2 | ||
| + | |||
| + | #防范 WordPress 暴力破解登录请求 | ||
| + | [wp-login] | ||
| + | enabled = true | ||
| + | port = http,https | ||
| + | filter = wp-login | ||
| + | maxretry = 10 | ||
| + | findtime = 60 | ||
| + | bantime = 43600 | ||
| + | logpath | ||
| + | |||
| + | #防止 WordPress 受到 xmlrpc.php CC 攻击 | ||
| + | [xmlrpc] | ||
| + | enabled = true | ||
| + | port = http,https | ||
| + | filter = xmlrpc | ||
| + | logpath | ||
| + | bantime = 43600 | ||
| + | maxretry = 1 | ||
| + | findtime | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | |||
| + | |||
| + | |||
