我正在尝试使用 libpam-google-authenticator 通过 ssh 启用 2FA。并非所有用户都需要启用身份验证器。每个人都使用 ssh 公钥,但没有人有密码。我正在运行 Debian buster,并且还尝试了 bullseye 的 libpam-google-authenticator。
我的问题是,无论我在 PAM 配置中输入什么内容,未启用身份验证器的用户都不会直接登录,而是总是要求输入密码。
我已经安装了 libpam-google-authenticator 并配置了 /etc/ssh/sshd_config:
PasswordAuthentication no
ChallengeResponseAuthentication yes
AuthenticationMethods publickey,keyboard-interactive
PasswordAuthentication no
PermitEmptyPasswords no
Run Code Online (Sandbox Code Playgroud)
我无法计算出正确的 PAM 配置,以便没有 .google_authenticator 文件的用户仍然可以登录。根据我使用的内容,系统要么提示用户输入密码(他们没有密码),要么不提示完全允许进入。
在 /etc/pam.d/sshd 中,我尝试过(像这样Trying to get SSH with public key (no password) + googleauthenticatorworking on Ubuntu 14.04.1):
#@include common-auth
auth required pam_google_authenticator.so debug nullok
Run Code Online (Sandbox Code Playgroud)
在这种情况下,没有身份验证器设置的用户将通过以下调试被拒绝;
Aug 05 15:11:18 <host> sshd(pam_google_authenticator)[746624]: debug: start of google_authenticator for "<user>"
Aug 05 15:11:18 <host> sshd(pam_google_authenticator)[746624]: debug: …
Run Code Online (Sandbox Code Playgroud)