I have setup a few GNU/Linux (Ubuntu and Amazon Linux) servers to prompt for Time-Based OTP using google-authenticator
module for PAM and the keyboard-interactive:pam
SSHD authentication method. I'm struggling to get ansible to prompt me for the OTP. The --ask-pass
flag asks for the password before making the connection and passes it when making the connection. What I need is for ansible to just pass on the OTP request from SSHD on the servers to my shell. Is there a way I can do that?
Currently, ansible does not reliably pass on the response back to the server.
➜ 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
}
sshd_config on amazon1
...snip...
UsePAM yes
PubkeyAuthentication yes
ChallengeResponseAuthentication yes
AuthenticationMethods publickey,keyboard-interactive:pam
...snip...
pam config on amazon1
#%PAM-1.0
auth required pam_sepermit.so
auth required pam_google_authenticator.so
...snip...
Normally, SSH works like this:
➜ 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 ~]$
I know I can exclude a specific user from being prompted for OTP in sshd_config. I do not want to do that, however. I hope I'm not missing an obvious ansible flag for this. Thanks in advance.