多次 SSH 登录尝试失败后,IP 会被封锁几分钟

多次 SSH 登录尝试失败后,IP 会被封锁几分钟

在几次错误的登录尝试(使用密码)之后,我的 IP 被阻止了,并且几分钟内我无法通过 SSH 进入 Ubuntu 服务器。

我不希望发生这种情况(至少对于我的 IP 来说)。事实上,我想在我的服务器上将我的 IP 列入白名单。但我不知道在哪里做。我已禁用 ufw。我不使用fail2ban,我不使用pam_tallypam_faillock。我已安装libpam-google-authenticator双因素身份验证和pam_cracklib.so强密码策略。事实上,我甚至不知道是什么阻止了我的 IP 尝试失败。我的以下文件/etc/pam.d

 atd
 chfn
 chpasswd
 chsh
 common-account
 common-auth
 common-password
 common-session
 common-session-noninteractive
 cron
 login
 newusers
 other
 passwd
 polkit-1
 runuser
 runuser-l
 sshd
 su
 sudo
 systemd-user
 vmtoolsd

有人能告诉我我该怎么做才能让我的 IP 不会因为身份验证失败而被阻止吗?

sshd_config文件中我已设置MaxAuthTries 20。但 ssh 在 8 次错误尝试内失败。并且没有关于阻止时间或白名单的任何信息。

上次发生这种情况时,/var/log/auth.log 中的最后几个条目如下所示。

Aug 26 15:04:24 Bastion sshd(pam_google_authenticator)[2661]: Did not receive verification code from user
Aug 26 15:04:24 Bastion-ip-10-0-1-45 sshd(pam_google_authenticator)[2661]: Invalid verification code for username
Aug 26 15:04:26 Bastion sshd[2657]: error: PAM: Authentication failure for username from xxx.xxx.xxx.xxx
Aug 26 15:04:27 Bastion sshd(pam_google_authenticator)[3247]: Did not receive verification code from user
Aug 26 15:04:27 Bastion sshd(pam_google_authenticator)[3247]: Invalid verification code for username
Aug 26 15:04:29 Bastion sshd[2657]: error: PAM: Authentication failure for username from xxx.xxx.xxx.xxx

xxx.xxx.xxx.xxx 是被阻止的 IP。

答案1

我能够找出问题所在。这是 OSSEC。我在服务器上还安装了 ossec-hids 代理。ossec 中的主动响应功能会阻止 ssh 失败的 IP。通过在 ossec 管理器中的 ossec.conf 文件中的全局块 <white_list>1.2.3.4</white_list> 内添加要忽略的 IP 来解决此问题。感谢大家提供的所有有用提示。

相关内容