Ansible 安装后的两个常见错误及处理

本文介绍了在使用Ansible时遇到的两个常见SSH错误:一是由于Host Key检查导致的连接失败,二是由于缺少SSH认证信息造成的权限拒绝。解决方法包括禁用SSH主机键检查和通过ssh-copy-id添加目标主机的SSH认证信息。
摘要由CSDN通过智能技术生成

I. 对之前未连接的主机进行连结时报错如下:
[root@linux ~]# ansible webservers -m command -a ‘ls ~’ -k
SSH password:
120.76.25.191 | FAILED | rc=0 >>
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.

解决步骤:修改ansible.cfg文件

  1. vi /etc/ansible/ansible.cfg
  2. 找到以下行,让host_key_checking=False这行生效

uncomment this to disable SSH key host checking

host_key_checking = False

II. 在ansible安装完毕后一般需要以SSH的方式连接到需要进行管理的目标主机,一开始遇到了如下问题:

120.76.25.191 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n”,
“unreachable”: true
}<

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值