ansible执行命令报错Using a SSH password instead of a key is not possible because Host Key checkingis enabl

Ansible报错“Using a SSH password instead of a key is not possible because Host Key checking is enable” 主机第一次进行ssh连接,需要输入一个yes将key字符串加入到 ~/.ssh/known_hosts 文件中。 阅读详情
AI摘要

博客指出ansible执行命令报错,原因是本机~/.ssh/known_hosts文件中无fingerprint key串。给出两种解决方法,一是本地先SSH登录对方设备,但较麻烦;二是设置参数为不检查key,修改/etc/ansible/ansible.cfg配置文件,重新执行命令可解决问题。

ansible执行命令报错

192.168.100.10 | FAILED | rc=-1 >>
Using a SSH password instead of a key is not possible because Host Key checkingis enabled and sshpass does not support this. Please add this host’s fingerprint to your known_hosts file to manage this host.

从输出提示上基本可以了解到由于在本机的~/.ssh/known_hosts文件中并有fingerprint key串,ssh第一次连接的时候一般会提示输入yes 进行确认为将key字符串加入到 ~/.ssh/known_hosts 文件中

基于这个原因,可以修改/etc/ansible/ansible.cfg配置文件

hosts配置如下:
vi /etc/ansible/hosts

[local]
127.0.0.1
[test1]
192.168.100.11  ansible_ssh_user=root ansible_ssh_pass=123456
[test2]
192.168.100.12  ansible_ssh_user=root ansible_ssh_pass=123456
[test3]
192.168.100.10  ansible_ssh_user=root ansible_ssh_pass=123456
[test4]
192.168.100.9  ansible_ssh_user=root
"/etc/ansible/hosts" 53L, 1301C

解决方法两种:

第一种:在本地先SSH登录一下对方设备,下次ansible 就可以正常操作了,但是比较麻烦

[root@shanan ~]# ssh root@192.168.100.11
The authenticity of host '192.168.100.11 (192.168.100.11)' can't be established.
ECDSA key fingerprint is SHA256:z+83zi+ptU8EEYf7ccqK5tDPDLa8ekQe+pKQ+UKX72Y.
ECDSA key fingerprint is MD5:a9:be:c0:fa:44:1b:e6:84:83:78:55:2b:9f:88:c7:d6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.11' (ECDSA) to the list of known hosts.
root@192.168.100.11's password:
Last login: Sat Dec 26 19:39:43 2020 from 192.168.100.1

第二种:设置参数为不检查key

vi /etc/ansible/ansible.cfg
在文件中进行搜索定位到

:/host_key_checking

# uncomment this to disable SSH key host checking
#host_key_checking = False
修改后:

# uncomment this to disable SSH key host checking
host_key_checking = False

保存退出,重新执行命令测试:
解决!!!

[root@shanan ~]# ansible test3  -a 'ls'
192.168.100.10 | CHANGED | rc=0 >>
anaconda-ks.cfg
original-ks.cfg
下载
公共
图片
文档
桌面
模板
视频
音乐
ansible:Using a SSH password instead of a key is not possible because Host Key checking 问题背景 当设置好ansible的hosts后,尝试用ansible去连接host里设置的主机。 我使用的是162主机去连接163主机: 如果你之前从来没有连接过163主机,执行后会报错 [root@itlaoxin162 ~]# ansible -i /etc/ansible/hosts web-servers -m ping [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see 阅读详情

相关推荐

从零到一:高通Memory QMVS测试环境搭建的避坑指南

本文详细介绍了高通Memory QMVS测试环境搭建的全流程避坑指南,涵盖硬件选择、软件配置、QMVS核心组件安装及测试执行技巧。重点解析了adb工具配置、QPST日志抓取等关键步骤,帮助工程师高效搭建稳定测试环境,避免常见兼容性和稳定性问题。

weixin_29251567的博客 561

Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpa

1.原因是以为/etc/ansible/ansible.cfg配置里默认是用know_hosts免密登录, host_key_checking = False 前边的#去了,就可以使用密码登录了。

weixin_45447033的博客 1179

一文告诉你:如何在trae中编译运行STM32程序,并让AI帮你修改代码

本文详细介绍了如何将STM32程序从Keil迁移到国产免费工具Trae,并利用AI进行代码修改的全过程。

水滴爬呀爬 4967

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

运行ansible出错 [root@ansible ~]# ansible webservers -m ping -u root -k SSH password: 192.168.154.130 | FAILED! => { "msg": "Using a SSH password instead of a key is not possible because Host Key...

大鱼的博客 2万+

推荐系统:NDCG评价指标及其Python实现方法

除了推荐任务,在二分类任务中,也可以计算该指标,代码如下: # ndcg def get_dcg(y_pred, y_true, k): #注意y_pred与y_true必须是一一对应的,并且y_pred越大越接近label=1(用相关性的说法就是,与label=1越相关) df = pd.DataFrame({"y_pred":y_pred, "y_true":y_true}) ...

lanyuelvyun的博客 8247

WPF MVVM实战:构建可绑定的RichTextBox富文本编辑器

本文详细介绍了如何在WPF MVVM模式下构建可绑定的RichTextBox富文本编辑器,解决标准RichTextBox.Document属性不支持数据绑定的问题。通过创建自定义BindableRichTextBox控件,实现FlowDocument的绑定支持,并分享插入图片、文本格式控制等实战技巧,帮助开发者高效开发富文本编辑功能。

weixin_33717117的博客 309

ansible:Using a SSH password instead of a key is not possible because Host Key checking is enable

第一次通讯失败 解决办法: ansible默认会找当前目录下的cfg文件 关于ansible找cfg文件的顺序 我自己在当前目录下建了一个cfg文件,直接在这里修改就行,当前目录没有的话,就修改/etc/ansible/ansible.cfg文件,添加host_key_checking = False即可 [defaults] inventory = hosts remote_user = root host_key_checking = False ...

河静 3495

智能体在车联网中的应用:第9天 核心工具链与仿真世界:SUMO交通仿真入门——从安装到构建你的第一个虚拟十字路口

摘要 SUMO是一款开源微观交通仿真工具,为车联网和自动驾驶算法开发提供高效安全的测试环境。文章详细介绍了SUMO的核心概念、安装方法及实战应用。在Ubuntu或Windows系统安装SUMO后,可通过netedit工具构建十字路口路网,包括创建节点、连接边、设置交通信号灯等步骤。随后通过编写.rou.xml文件定义车辆类型、路线和车流,实现动态交通场景模拟。SUMO支持与外部程序交互,能复现真实场景、进行极端测试和算法验证,是车联网研究的理想数字沙盘。

IT深耕十余载,大道之简 1474

ansible开启hostchecking报错

1、ansible的配置文件hosts,如果配置了ssh_user,ssh_pass;但是配置文件ansible.cfg中开启host_key_checking 执行命令会失败,报错如下: | FAILED | rc=-1 >> Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please

qq_34217914的博客 2492

【Embabel Agent】生产级最佳实践与避坑指南

本文围绕架构师最关心的 8 大维度展开:测试策略(FakeOperationContext 实现 Action 级单元测试、Prompt 质量与敏感信息校验)、MCP 集成实战(STDIO/HTTP 双模式、自建 Server、Docker MCP 生态)、RAG 检索增强、OpenTelemetry 全链路可观测性与追踪、Docker/K8s 生产部署、API Key 管理与 @Tool 安全防护、模型选择/缓存/并行等性能优化,以及过度依赖 LLM、忽略错误处理等 8 大常见反模式避坑指南。

program哲学 317

CLRNet车道线检测模型在Orin Nano Super开发板上的全栈部署与优化实践

本文详细介绍了将CLRNet车道线检测模型部署到NVIDIA Orin Nano Super开发板的全过程。内容包括:1) Orin开发板硬件规格分析;2) JetPack SDK环境配置与Python虚拟环境搭建;3) CLRNet模型架构解析与PyTorch实现;4) 模型转换与TensorRT加速优化方法。通过系统性的环境配置、模型转换和性能优化,为边缘计算场景下的车道线检测应用提供了完整的解决方案,实现了在Orin平台上的高效部署。

huanghm88的专栏 235

ansible自动化运维排错思路

使用ansible之前要做密钥认证。

weixin_70099460的博客 1167

从苏宁电器到卡巴斯基第02篇:我的本科时光(中)

怎么还分班了呢? 大概是在大二第二学期的时候吧,学院突然通知我们要分班。因为我们目前所有学生都是属于工商管理专业的,而从下个学期开始,就要分为会计、市场营销以及工商管理这三个方向。这还真是打了我一个措手不及,我都不知道还有分班这一回事。不过也没关系,我继续选择我的工商管理就好了。不过,在实际的选择结果上,像会计和工商管理这种学科,选的人自然是占了绝大多数,而选择市场营销的,大概也就是十

Gleam的专栏 9613

ansible采用密码认证方式。报:to use the ‘ssh‘ connection type with passwords, you must install the sshpas

ansible采用密码认证方式。报:to use the 'ssh' connection type with passwords, you must install the sshpas

weixin_48595415的博客 4486

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Ansible 部署的时候提示错误 SSH password instead

在使用 Ansible 部署的时候提示: fatal: [*.*.*.*]: FAILED!在我们 SSH 到服务器上的时候,SSH 会提示是否需要保存 key,这个时候我们需要选择 Yes 或者 No。Ansible 部署的时候提示错误 SSH password instead - DevOps - OSSEZ。配置文件位于:/etc/ansible/ansible.cfg。上面的错误信息的主要原因是我们远程到 SSH 服务器上。但,Ansible 是不具备输入参数的能力的。添加上面的参数后重新部署。

HONEY MOOSE 1084

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled a...

Centos7.5 ansible第一次使用模块报错 问题: [root@m01 ~]# ansible webservers -m ping -i ./hosts 172.16.1.7 | FAILED! => { "msg": "Using a SSH password instead of a key is not possible because Host Key check...

weixin_34125592的博客 2070

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

ansible初次连接报错解决办法

ansible初次连接报错解决办法 Using a SSH password instead of a key is not possible because Host Key checking [root@localhost yum.repos.d]# ansible webservers -m ping -o host1 | FAILED! => {"msg": "Using a SS...

qq_31210337的博客 2034

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

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

qq_36546177的博客 4614

ansible常见问题配置好了密码还是报错

确保known_hosts文件位于正确的位置(通常在用户的.ssh目录下),然后再次尝试连接到目标主机。将公钥添加到目标主机的authorized_keys文件中。然后,将目标主机的指纹添加到known_hosts文件中。输入密码后,你的公钥将被添加到目标主机的authorized_keys文件中。再次连接到目标主机时,SSH将使用密钥进行身份验证,而不需要密码。这将生成一个RSA密钥对,默认会保存在~/.ssh目录下。首先,使用ssh连接到目标主机,并接受指纹。当提示是否接受该主机的指纹时,输入yes。

weixin_45631123的博客 673

ansible报错“msg“: “Using a SSH password instead of a key is not possible because Host K

"msg": "Using a SSH password instead of a key is not possible because Host K

qq_40077805的博客 920

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

安装和配置好ansible,执行命令时报错如下 [root@test01 ansible-install]# ansible test -m shell -a 'w' 10.xx.37.26 | FAILED | rc=-1 >> Using a SSH password instead of a key is not possible because Host Key ch...

weixin_33910434的博客 510

ubuntu18 kolla-ansible安装最全组件openstack

ubuntu18 kolla-ansible安装最全组件openstack 持续更新 preparation TLS handshake process RFC 8446 - The Transport Layer Security (TLS) Protocol Version 1.3 Certificate_authority Certificate authority - Wikipedia OpenStack Docs: Advanced Configuration Self-signed SSL

albertjone的博客 1万+
上一篇: 深入kubernetes调度之NodeSelector
下一篇: ansible模块管理与主机清单配置
BIGmustang
博客等级 码龄7年 142粉丝 169原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值