我已经安装了几个GNU / Linux(Ubuntu和Amazon Linux)服务器,以便使用PAM的google-authenticator
模块和keyboard-interactive:pam
SSHD身份validation方法来提示基于时间的OTP。 我正在努力争取让我进入OTP。 在进行连接之前,– --ask-pass
标志要求提供密码,并在进行连接时传递该密码。 我需要的是只要将来自服务器上SSHD的OTP请求传递给我的shell。 有什么办法可以做到吗?
目前,ansible不能可靠地将响应传递回服务器。
➜ ansible git:(master) ✗ ansible -m ping amazon1 --inventory-file=./ansible_hosts Verification code: <I QUICKLY ENTER THE OTP HERE> amazon1 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true }
在amazon1上的sshd_config
...snip... UsePAM yes PubkeyAuthentication yes ChallengeResponseAuthentication yes AuthenticationMethods publickey,keyboard-interactive:pam ...snip...
在amazon1的pamconfiguration
#%PAM-1.0 auth required pam_sepermit.so auth required pam_google_authenticator.so ...snip...
通常,SSH的工作原理是这样的:
➜ ansible git:(master) ✗ ssh amazon1 Verification code: Last login: Sun Mar 12 04:32:37 2017 from ip-10-0-1-23.ec2.internal [admin@amazon1 ~]$
我知道我可以在sshd_config中排除一个特定的用户被提示inputOTP。 不过,我不想这样做。 我希望我不会错过这个显而易见的标志。 提前致谢。
不,Ansible不想支持这个问题,正如github问题所讨论的那样:
是的,不是我们马上要支持的东西。
你应该真的考虑SSH密钥。
正如已经指出的那样,Ansible目前不支持双因素身份validation。
似乎有两个select来解决这个警告:
我使用duo auth来解决这个问题,通过在pam_duo.conf和login_duo.conf中排除负责任的用户组,然后在sshd_config中设置以下内容:
Match User ansible AuthenticationMethods publickey
所以有效地禁用Ansible用户的双因素authentication。
我终于实现了类似的东西: http : //blog.scottlowe.org/2015/12/24/running-ansible-through-ssh-bastion-host/
我打开与2FA的主机的初始连接,然后在另一个窗口运行如下所示:
ansible-playbook thing.yml --ssh-common-args='-o ControlPath=~/.ssh/connshare'
看看这个github问题的讨论。