Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
Please, set the sshd server side LogLevel to DEBUG and add the output. –  dawud Jul 17 at 6:44
    
I noticed in pastebin 4th line 'PasswordAuthentication=no' and in your 1st quote 2nd line Enter passphrase for key '/home/basicuser/.ssh/id_rsa': - can you create a passphraseless ssh key and use that to test if that is the issue? –  Dani_l Jul 17 at 7:20
    
Are you using an encrypted filesystem? –  Antonis Christofides Jul 17 at 8:21
    
Non-encrypted fs. Dani / dawud - will let you know shortly after I try these –  Sam Levin Jul 17 at 17:14

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.