为什么当我通过 ssh 进入我的 ubuntu 服务器时我的验证码不起作用?

为什么当我通过 ssh 进入我的 ubuntu 服务器时我的验证码不起作用?

我正在尝试在我的 Ubuntu Server 20.04 机器上设置 Google 多重身份验证,以便当我通过 ssh 进入机器时,它将需要来自 Google 身份验证程序的 ssh 密钥和验证码。

到目前为止,我已经安装了 google authenticator,运行了命令google-authenticator并完成了设置过程,包括将生成的配置代码放入将生成验证码的身份验证应用程序中。

我已将以下行添加/更改/etc/pam.d/sshd为:

#@include common-auth
auth required pam_google_authenticator.so

并将“/etc/ssh/sshd_config”中的行添加/更改为:

LoginGraceTime 20
PermitRootLogin no
MaxAuthTries 3
PasswordAuthentication no
PubkeyAuthentication yes
AuthenticationMethods publickey,keyboard-interactive
DebianBanner no

ChallengeResponseAuthentication yes
UsePAM yes

我不认为这是我的验证码生成器的问题,因为当我在本地登录时,它会要求输入验证码,并且毫无问题地接受。只有当我通过 PuTTY ssh 进入机器时才会出现问题。

login as: [REDACTED]
Authenticating with public key "rsa-key-20220414"
Further authentication required
Keyboard-interactive authentication prompts from server:
| Verification code:
| Verification code:
End of keyboard-interactive prompts from server
Access denied
Keyboard-interactive authentication prompts from server:
| Verification code:

谢谢!

相关内容