pem键的Ansible库存参数

时间:2015-06-09 11:02:31

标签: macos ansible

我刚刚开始使用Ansible,但我遇到了各种各样的问题。最新的是我的ssh键并没有被主持人接收。库存文件。文件的内容是:

[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

执行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}

当我通过命令行传递用户和私钥时,我得到了同样的错误。当我通过ssh-add添加密钥时,我才能成功ping。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我不确定问题究竟是什么,但我想知道它是否与主机已经在我的~/.ssh/config文件中有关。

我通过简单地引用我的~/.ssh/config文件中描述的主机名来解决这个问题。我按照这里的开头说明进行操作:http://benincosa.com/?p=2651