lorin/ansiblebook

ssh forwarding problem with git in ch06

arglucas opened this issue · 3 comments

On my OSX 10.10 machine i had a problem with the git step in the mezzanine config. I would get public key denied and with debugging was able to show that agent forwarding was not working. (I had ensured that the ssh-agent was running and that my github key was ssh-add'd to the agent).

Solution for me was to add to the ansible.cfg file so that it looks as follows on the ssh_args line:

[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null

I actually had the same problem - thanks!

I'm having the same problem on OSX 10.10.5, but adding UserKnownHostsFile=dev/null isn't fixing it for me. I haven't modified anything from the provided code, except where explicitly noted below.

For reference, I:

  • am running ansible 1.9.4
  • have confirmed that ssh-agent is running
  • have run ssh-add on my key (with the -K flag for compatibility with the OSX keychain).
  • can see my key listed when I run ssh-add -l
  • get the successful confirmation message from Github when I run ssh -T git@github.com.
  • get the same successful message when I run ssh -T git@github.com from inside the VM after connecting to it with vagrant ssh.

However, if I use ansible to ssh in to the VM and try to call Github, the call fails:

$: ansible web -a "ssh -T git@github.com"
web | FAILED | rc=255 >>
Permission denied (publickey).

Which makes the result from the git play not too surprising:

TASK: [check out the repository on the host] ********************************** 
failed: [web] => {"cmd": "/usr/bin/git ls-remote '' -h refs/heads/HEAD", "failed": true, "rc": 128}
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

If I'm interpreting this correctly, my agent forwarding is working correctly when done manually through vagrant ssh, but failing from inside ansible. That's despite having my ansible.cfg set up with the ForwardAgent=yes flag. At this point, I'm at something of a loss as to what to try next.

I am still having this issue. I've tried everything from regenerating a new ssh key file to creating and killing several agents. I've learned a lot, but been completely unable to solve it. Here's my latest SO post asking about the issue and covering all the work I've done: http://stackoverflow.com/questions/33656916/ansible-with-github-permission-denied-publickey