Skip to main content

6.Ansible报错

报错:ERROR! to use the 'ssh' connection type with passwords, you must install the sshpass program

**解决方案:**一般出现这种错误,是在通过密码验证远程被管理机的时候,需要在server端安装sshpass:

yum install sshpass -y 

报错:Using a SSH password instead of a key is not possible because Host Key checking is

enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host

**解决方案:**这种错误通常就出现在server端第一次连接被管理机的时候,就是上面说到的需要通过输入yes/no进行确认将key字符串加入到 ~/.ssh/known_hosts 文件中。

解决办法有两个:

  • 通过修改上面提到的host_key_cheking,将其设置为false。(可能无效)

  • 通过修改ssh_args参数,修改如下:

    ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no