Can anyone possibly shed any light on why this is happening?
I am logged into machine A, the client, with user basicuser. When I try to run an ansible playbook on machine B (server machine, as remoteuser).
- 1) My private/public keys DEFINIELY match, as is made evident by "ssh user@serverB" working on client A (as basicuser) – ansible and SSH are both pointing to the same private key
- 2) My ~/.ssh/known_hosts is not outdated
- 3) my ~/.ssh and ~/.ssh/* permissions are correct (owned by basicuser, chmod 700 respectively
- 4) My hosts.ini file contains the required "ansible_ssh_user=remoteuser ansible_ssh_private_key_file=~/.ssh/id_rsa" (and is correctly formatted)
I know that id_rsa matches up to the only entry on machine B's "authorized_keys" file in /home/remoteuser/.ssh.
Here is SSH from client A through terminal:
basicuser@serverA:~$ ssh remoteuser@serverB
Enter passphrase for key '/home/basicuser/.ssh/id_rsa':
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
Last login: Wed Jul 16 23:38:41 2014 from xxx.xxx.xxx.xxx
remoteuser@serverB:~$
Here is what happens when I run an ansible playbook: http://pastebin.com/6wXgp3dd
I placed it on pastebin because it's quite a bit of output. However, what strikes me as odd is this bit toward the end:
debug2: key: /home/basicuser/.ssh/id_rsa ((nil))
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-with-mic,gssapi-keyex,hostbased,publickey
debug3: authmethod_lookup publickey
debug3: remaining preferred: ,gssapi-keyex,hostbased,publickey
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/basicuser/.ssh/id_rsa
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: read PEM private key done: type RSA
debug3: sign_and_send_pubkey: RSA ed:bb:6d:4e:e3:7a:54:0a:19:f6:ee:1c:d0:f2:1b:3f
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
I have spent about three days on this now. Why on earth is the terminal SSH working, but ansible's is failing?
I don't have any overrides in /etc/ssh/ssh_config – do I need any?
Best Answer
After much tweaking and coffee, I figured out what I did wrong. I had the "ansible_ssh_user" parameter duplicated amongst my hosts.ini and my deployment file - but not the private key parameter. That said, I am going without a passphrase on my ssh key! I had to enter the phrase WAY too many times.
Thanks for the insight guys