使用Google身份验证器时的SSH连接

问题描述 投票:0回答:1

我想问一个可能没有真正答案的问题,但它将挽救我的生命。

所以昨天我开始在所有服务器上使用google-authenticator进行第二因素身份验证。

我正在用Ansible配置我的所有主机,因此很明显与它建立连接对我来说非常重要,因此,我所做的就是将这行添加到我的/etc/pam.d/ssh文件中

auth [success=done default=ignore] pam_access.so accessfile=/etc/security/access-local.conf

我认为如果满足我在/etc/security/access-local.conf中添加的规则,这将返回成功

#localhost doesn't need two step verification
+ : ALL : <<localnetworkip>>/24
+ : ALL : LOCAL
#All other hosts need two step verification
- : ALL : ALL

因此,我允许本地网络中的任何计算机。当我尝试从ansible切换到主机(它不要求我提供验证码)时,这项工作有效,但是当我尝试在同一本地IP上运行ansible剧本时,我得到:

致命:[主持人]:没空! => {“更改”:false,“ msg”:“无法通过ssh连接到主机:权限被拒绝(键盘交互)。”,“无法访问”:true}

我认为Ansible不知道如何处理键盘交互,有人设法绕过它吗?

谢谢

ansible google-authentication pam sshd google-authenticator
1个回答
0
投票

因此,我至少想出了如何避免这种情况的方法。

我在/ etc / ssh / sshd_config的末尾添加了以下规则

Match Address <<localnetworkip>>/24
    AuthenticationMethods publickey keyboard-interactive

因此,从内部网络不再需要Google身份验证

© www.soinside.com 2019 - 2024. All rights reserved.