使用Google Authenticator时的Ansible SSH连接

使用Google Authenticator时的Ansible SSH连接,ansible,google-authentication,pam,sshd,google-authenticator,Ansible,Google Authentication,Pam,Sshd,Google Authenticator,我想问一个可能没有答案但能救我一命的问题 所以昨天我开始在我所有的服务器上使用GoogleAuthenticator进行第二因素身份验证 我正在用Ansible配置我的所有主机,所以对我来说从它建立连接非常重要。显然,我所做的是,我将这一行添加到我的/etc/pam.d/ssh文件中 auth [success=done default=ignore] pam_access.so accessfile=/etc/security/access-local.conf 我认为,如果我满足我在/et

我想问一个可能没有答案但能救我一命的问题

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

我正在用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
#localhost不需要两步验证
+:全部:/24
+:全部:本地
#所有其他主机都需要两步验证
-:全部:全部
因此,我允许任何机器从我的本地网络。当我尝试使用ssh从ansible连接到主机时(它不要求我提供验证代码),但当我尝试在同一本地IP上运行ansible playbook时,我得到了以下结果:

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

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


谢谢你

所以我想出了至少在我的案例中如何绕过这个

我在/etc/ssh/sshd\u config的末尾添加了以下规则

Match Address <<localnetworkip>>/24
    AuthenticationMethods publickey keyboard-interactive
匹配地址/24
身份验证方法公钥键盘交互

所以谷歌认证不再是来自内部网络的强制性认证,所以我想至少在我的案例中如何绕过它

我在/etc/ssh/sshd\u config的末尾添加了以下规则

Match Address <<localnetworkip>>/24
    AuthenticationMethods publickey keyboard-interactive
匹配地址/24
身份验证方法公钥键盘交互
所以谷歌认证不再是来自内部网络的强制性认证