ssh与密码,回退到Google Authenticator

随着Google身份validation器的引入以及与ssh一起使用的能力,我想知道是否有人通过了sshd_config安装程序

  • 首先期待一个关键
  • 如果失败,则回退到使用Google Authenticator的身份validation

这个想法通常与一个密钥无缝连接,并且通常在不太友好的环境中连接一个双因素机制。

是的,我有一个设置,我可以使用公共密钥authenticationssh到我的服务器,当我的私钥不可用时,使用Google Authenticator +密码回退到双因素authentication。 这些是你可以用来设置它的步骤。

安装Google Authenticator

我的服务器正在运行Ubuntu Trusty Tahr(14.04.1)。 您可以使用aptitude安装Google Authenticator:

 $ sudo aptitude install libpam-google-authenticator 

configurationsshd

打开/etc/pam.d/sshd并在顶部添加以下行:

 auth optional pam_google_authenticator.so 

打开/etc/ssh/sshd_config并更改一行。 现有的路线是

 ChallengeResponseAuthentication no 

你应该改变它

 ChallengeResponseAuthentication yes 

为您的帐户configurationGoogle身份validation器

下一步是打开您的帐户的Google身份validation器。 你只需要运行:

 $ google-authenticator 

确保你运行这个用户谁将使SSH连接, 而不是根。 记下您的新密钥和紧急防盗码。 向导会问你几个问题来configuration你的账户的安全设置。

configuration您的移动应用

我使用iPhone的Google Authenticator应用程序。 这个应用程序有一个[+]button,允许我使用从我的服务器上的google-authenticator命令获得的密钥添加新的基于时间的令牌。 这是微不足道的设置。 我无法帮助您在任何其他平台上使用应用程序,但我想这个过程同样简单。

拉动触发器

你需要做的最后一件事是重新启动sshd

 $ sudo /etc/init.d/ssh restart 

此时,当您的私钥可用时尝试连接到服务器时,身份validation正常工作。 当您的私钥不可用时,您将收到提示inputvalidation码,然后是您的帐户密码。

宾果,双因素authentication。