以下是我的主机文件/etc/ansible/hosts
root@ubuntu:/home/dasitha# cat /etc/ansible/hosts
[web]
10.0.0.112 ansible_user=root
[local]
127.0.0.1 ansible_user=root
当我执行ansible all -m ping -vv
以下错误抛出时。
ansible 2.5.3
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.6 (default, Jun 22 2015, 18:00:18) [GCC 4.8.2]
Using /etc/ansible/ansible.cfg as config file
META: ran handlers
10.0.0.112 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n",
"unreachable": true
}
127.0.0.1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n",
"unreachable": true
}
答案 0 :(得分:2)
由于ssh在ansible控制器和远程机器之间工作,可能是由于ssh由于认证方式失败而拒绝登录。你可能没有交换ssh密钥进行无密码登录,而且你的命令也没有提供密码。
要提供ad-hoc命令,例如您尝试过的密码,请在最后传递--ask-pass
标记:
[ilias@optima-ansible ~]$ ansible greenhat -m ping --ask-pass
SSH password:
greenhat | SUCCESS => {
"changed": false,
"ping": "pong"
}
[ilias@optima-ansible ~]$
没有旗帜:
[ilias@optima-ansible ~]$ ansible greenhat -m ping
greenhat | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ilias@greenhat: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
"unreachable": true
}
[ilias@optima-ansible ~]$
希望有所帮助
答案 1 :(得分:0)
Ansible假设您使用的是无密码(基于密钥)的SSH登录。如果您坚持使用密码,请在Ansible命令中添加 Y Position 0 Y Position [1] [mm]
2 3 8
3 4 9
4 5 0
标志(您可能还需要安装--ask-pass ( -k )
软件包才能起作用)。
sshpass