Ansible SSH passwd 认证成功,但 publickey 认证失败

Ansible SSH passwd authentication successful, but publickey authentication fails

使用 ansible 时,我使用以下参数进行身份验证:

-u bob -k -K -b 

我得到了我想要的输出,但事实证明 Ansible 在每个系统上都未能通过公钥身份验证。

来自 /var/log/secure 在其中一个收件人系统上的选定输出:

Failed publickey for bob from $IP port $PORT ssh2

Accepted password for bob from $IP port $PORT ssh2     

我正在阅读文档,但我还没有找到一种方法来防止 Ansible 尝试使用 passwd 身份验证以外的任何东西。

感谢任何帮助。

在适用的地方添加 SSH 客户端选项 -o PreferredAuthentications=password(Ansible 清单、额外变量、ssh-config 等)。

例如,对于主机文件:

[myhosts]
host1 ansible_host=X.X.X.X ansible_ssh_extra_args="-o PreferredAuthentications=password"