I'm just getting started with Ansible but I'm running into various issues. The latest is my ssh keys aren't being picked up by the 'hosts' inventory file. The file's contents are:
[my host]
my-dev ansible_ssh_host=54.79.31.51 ansible_ssh_private_key_file=/Users/dev/.ssh/dev.pem ansible_ssh_user=ec2-user
And the error I get when executing ansible all -m ping -vvvv
<54.79.31.51> ESTABLISH SSH CONNECTION FOR USER: ec2-user
<54.79.31.51> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/tmp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ec2-user -o ConnectTimeout=15 54.79.31.51 mkdir -p $HOME/.ansible/tmp/ansible-tmp-1433847411.11-150497316324808 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1433847411.11-150497316324808 && echo $HOME/.ansible/tmp/ansible-tmp-1433847411.11-150497316324808
my-dev | FAILED! => {'msg': u'ERROR! SSH encountered an unknown error. The output was:\nOpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011\ndebug1: Reading configuration data /Users/dev/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh_config\r\ndebug1:
...
No such file or directory\r\ndebug2: we did not send a packet, disable method\r\ndebug1: No more authentication methods to try.\r\nPermission denied (publickey).\r\n', 'failed': True}
I get the same error when I pass the user and private key via command line. I'm only able to successfully ping when I add the key via ssh-add
.
What am I doing wrong?
I'm not sure exactly what the issue is but I'm wondering if it might be related to the fact that the host is already in my
~/.ssh/config
file.I got around this by simply referring to the host name as it is described in my
~/.ssh/config
file. I followed the beginning instructions from here: http://benincosa.com/?p=2651