2FA不使用Ubuntu AWS实例

发布于 2025-01-17 12:15:12 字数 611 浏览 3 评论 0原文

我在 EC2 实例中执行 ssh 时致力于设置 2FA。但在设置实例之后仍然不要求 2FA 代码并直接将我的用户(即 ubuntu)登录到服务器。

我按照以下步骤设置 2FA:

  1. 安装 Google Authenticator PAM 模块。

    sudo apt install libpam-google-authenticator

  2. auth required pam_google_authenticator.so 添加到 /etc/pam.d/sshd

  3. 重新启动 ssh sudo systemctl restart sshd.service

  4. 使用以下内容更新 sshd_config:

    ChallengeResponseAuthentication 是 PasswordAuthentication 否

  5. 运行命令 google-authenticator

请帮助我解决此问题。提前致谢。

I worked on setting up 2FA while doing ssh in EC2 instance. But after the setup instance is still not asking for 2FA code and directly logs my user i.e. ubuntu into the server.

I did following steps to setup 2FA:

  1. Install Google Authenticator PAM module.

    sudo apt install libpam-google-authenticator

  2. Add auth required pam_google_authenticator.so to /etc/pam.d/sshd

  3. Restart ssh sudo systemctl restart sshd.service

  4. Update sshd_config with following:

    ChallengeResponseAuthentication yes PasswordAuthentication no

  5. Run command google-authenticator

Please help me resolve this issue. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温馨耳语 2025-01-24 12:15:12

我遇到这个问题是因为启用了其他配置。使用 PubKeyAuthentication 代替验证器。我将其更改为 PubKeyAuthentication no 解决了该问题。

I was facing this issue because of other configuration was enabled. PubKeyAuthentication was used instead of authenticator. I change it to PubKeyAuthentication no which resolved the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文