【问题标题】:Google two factor authentication not work on 'su' command谷歌两因素身份验证不适用于“su”命令
【发布时间】:2018-07-23 11:10:28
【问题描述】:

我在我的 linux 服务器上安装了谷歌双重身份验证。
(感谢:https://github.com/google/google-authenticator-libpam

当我尝试通过 ssh 访问 root 帐户时,身份验证器工作正常。

Verification code: .....  
Password: ....   
[root@hostname] works fine :)

但是!!访问其他用户帐户并尝试使用su 访问root 帐户, 验证器只需要密码。

[user@hostname] whoami   
user  
[user@hostname] su  
password: .....  
[root@hostname] What?!!!

我将所有配置设置为默认值。

我该如何解决??

【问题讨论】:

    标签: authentication two-factor-authentication one-time-password


    【解决方案1】:

    这是默认的工作方式。由于您使用的是google-authenticator-libpam 模块,因此您只需通过将auth required pam_google_authenticator.so 添加到sshd 配置文件来为实际的外部接口登录添加两个因素身份验证。

    正确的安全实现(或至少一种正确的方法)是不允许 root 用户进行外部登录,更进一步并锁定 ssh 以仅允许启用两因素身份验证的用户登录是偶数更好。

    为此,您需要在 sshd 配置中添加以下内容:

    AllowUsers admin bob
    

    【讨论】:

      【解决方案2】:

      要为su - 启用 Google 双重身份验证,您必须在文件 /etc/pam.d/su 的末尾添加以下参数:

      auth required pam_google_authenticator.so
      

      保存并尝试使用普通用户登录然后su -,它会提示输入验证码。 即无需重启sshd服务。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-11-25
        • 1970-01-01
        • 2021-01-11
        • 2021-10-14
        • 2019-07-21
        • 1970-01-01
        • 2014-05-30
        • 2017-12-31
        相关资源
        最近更新 更多