Ham*_*att 6 debian pam two-factor google-authenticator
我正在尝试使用 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: end of google_authenticator for "<user>" Result: The return value should be ignored by PAM dispatch
Aug 05 15:11:18 <host> sshd[746620]: error: PAM: Permission denied for <user> from <IP>
Run Code Online (Sandbox Code Playgroud)
是否pam_permit
需要设置后备案例?
我还尝试了前后auth required
的各种组合,但它们都会导致没有身份验证器的用户被要求输入密码,有时带有身份验证器的用户也会被要求输入密码。auth sufficient
@include common-auth
有人有一个食谱可以让这个工作吗?
这是我的工作配置。有些用户启用了身份验证器,有些则没有,并且只允许使用公钥进行 SSH 登录,而不允许使用密码。
在 /etc/ssh/sshd_config 中,
UsePAM yes
PasswordAuthentication no
ChallengeResponseAuthentication yes
AuthenticationMethods publickey,keyboard-interactive
PermitEmptyPasswords no
Run Code Online (Sandbox Code Playgroud)
在/etc/pam.d/sshd中,
# Standard Un*x authentication.
#@include common-auth
# Require authenticator, if not configured then allow
auth required pam_google_authenticator.so debug nullok
auth required pam_permit.so
Run Code Online (Sandbox Code Playgroud)
@include comon-auth
必须禁用,因为它包含我不想使用的 pam_unix。然后,您需要pam_permit
使没有身份验证器的用户身份验证成功(返回pam_google_authenticator
忽略而不是通过)。
这仍然不允许 root 使用 ssh 密钥登录;sshd 日志
sshd[1244501]: fatal: Internal error: PAM auth succeeded when it should have failed
Run Code Online (Sandbox Code Playgroud)
这在SSH 上的 Google Authenticator PAM 中讨论过,无需 2FA 即可阻止 root 登录。
如上所述完成此工作后,我认为按照 @zoredache 的建议使用 SSH 配置对某些组强制执行 2FA 实际上会更好。这使您可以轻松地将某些 IP 列入白名单,因为也不需要 2FA。在这种情况下,sshd_config 例如说
UsePAM yes
PasswordAuthentication no
ChallengeResponseAuthentication yes
#AuthenticationMethods any # default
PermitEmptyPasswords no
Match Group adm Address *,!172.16.1.0/24
AuthenticationMethods publickey,keyboard-interactive
Run Code Online (Sandbox Code Playgroud)
和 /etc/pam.d/ssh 说
Standard Un*x authentication.
#@include common-auth
# Require authenticator; SSH should not allow any user in who doesn't have it
auth sufficient pam_google_authenticator.so debug nullok
auth requisite pam_deny.so
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3474 次 |
最近记录: |