2FA不使用Ubuntu AWS实例
我在 EC2 实例中执行 ssh 时致力于设置 2FA。但在设置实例之后仍然不要求 2FA 代码并直接将我的用户(即 ubuntu
)登录到服务器。
我按照以下步骤设置 2FA:
安装 Google Authenticator PAM 模块。
sudo apt install libpam-google-authenticator
将
auth required pam_google_authenticator.so
添加到/etc/pam.d/sshd
重新启动 ssh
sudo systemctl restart sshd.service
使用以下内容更新 sshd_config:
ChallengeResponseAuthentication 是 PasswordAuthentication 否
运行命令
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:
Install Google Authenticator PAM module.
sudo apt install libpam-google-authenticator
Add
auth required pam_google_authenticator.so
to/etc/pam.d/sshd
Restart ssh
sudo systemctl restart sshd.service
Update sshd_config with following:
ChallengeResponseAuthentication yes PasswordAuthentication no
Run command
google-authenticator
Please help me resolve this issue. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到这个问题是因为启用了其他配置。使用 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.