大网数据广告活动
服务器运维问答

SSH choice of second factor on login

· 52CE 我爱测

Is it possible to have multiple 2FA pam's setup and give the user the choice of which to use on login? I have google-authenticator setup. I have successfully used my yubiko key as a second factor. I would like to have the choice …

问题原文

原帖链接 · DasPete · CC BY-SA 4.0

Is it possible to have multiple 2FA pam's setup and give the user the choice of which to use on login?

I have google-authenticator setup. I have successfully used my yubiko key as a second factor. I would like to have the choice of which to use on login so I can go with whatever is more convenient or to use one as a backup method.

已采纳解答

原帖链接 · HBruijn · CC BY-SA 4.0

There is, as far as I know, no standard/method that allows a user to select which MFA they want to use to login with from the commandline prompt during login. (But you could always write your own PAM module to do so ... #CurrentTeam did but didn't release that to the public domain.)

Not the most transparent for end-users, but something you can do with stock tools is to use PAM chaining to configure a fallback method.

Set the Yubico PAM module as sufficient and when you pass a valid One-Time-Password (OTP) you'll be granted access.

When what you entered does not validate as a correct Yubikey OTP, then authentication will fall through to the next allowed method, the Google-Authenticator PAM module.
That PAM module should be set to required.

If you then, after failing to enter a valid Yubibey OTP, enter a valid Google Authenticator code, you will be granted access and otherwise if you don't your authentication will be rejected.

That should somewhat similar to adding the following:

auth sufficient pam_yubico.so id=16 debug authfile=/path/to/mapping/file
auth required pam_google_authenticator.so

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-04-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。