【发布时间】:2017-08-08 09:57:30
【问题描述】:
我知道这已经被问了很多,但我已经尝试了我在网络上看到的所有解决方案,比如 20 个线程,但没有任何一个对我有用。
我在使用 ansible 2.1.1.0 的 Ubuntu 16.10 Linux 本地计算机上尝试 ping (ansible all -m ping) 我在 Ubuntu AWS EC2 实例上的 Ansible 子节点。
我的 /etc/ansible/hosts 有 EC2 的公共 IP:
web1 ansible_host=52.91.x.y
我可以通过 SSH 连接到 EC2 实例:
ssh -i "mypemfile.pem" ubuntu@52.91.x.y
所以我知道安全组/网络/等。在实例上很好。
但是当我尝试 ping 子节点时:
ansible all -m ping
我明白了:
Failed to connect to the host via ssh
当我通过 -vvvv 显示完整命令时:
ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/myuser/.ssh/id_rsa.pub"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/myuser/.ansible/cp/ansible-ssh-%h-%p-%r 52.91.x.y
然后运行 Ansible 正在运行的命令,在详细输出的末尾,它显示:
debug1: Offering RSA public key: /home/myuser/.ssh/id_rsa.pub
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: Downloads/nginx-code-challenge-2017-03-16.pem
...skip some stuff
debug1: No more authentication methods to try.
Permission denied (publickey).
它从我的本地(Ansible 主节点)系统尝试了一堆不同的密钥,但没有成功。
我确保我的主节点的公钥在子节点的.ssh/authorized_keys 中。当我执行 ssh-copy-id 时,它会确认这一点,说密钥已被添加。
我尝试在 /etc/ansible/ansible.cfg 中指定我的私钥的路径,但这没有任何作用,而且我已经在调试输出中看到它正在尝试多个密钥。
我已经尝试添加-c paramiko 命令:
ansible all -m ping -vvvv -c paramiko
但我得到的只是一个新错误,Authentication failed
我什至在 ansible.cfg 中尝试过像 host_key_checking = False 这样疯狂的东西
帮助?
【问题讨论】:
标签: ssh amazon-ec2 connection ansible