【ansible】Failed to connect to the host via ssh Permission denied

故障现象

yeqiang@yeqiang-MS-7B23:/data/VirtualBox VMs$ ansible all -m ping
node-2 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: \nAuthorized users only. All activities may be monitored and reported.\nyeqiang@node-2: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
"unreachable": true
}
node-3 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: \nAuthorized users only. All activities may be monitored and reported.\nyeqiang@node-3: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
"unreachable": true
}
node-1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: \nAuthorized users only. All activities may be monitored and reported.\nyeqiang@node-1: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
"unreachable": true
}

故障原因:

当前用户是yeqiang,而配置ssh-copy-id 是root,参考以下指令

复制代码
ssh root@node-1
ssh root@node-2
ssh root@node-3

解决

ansible指令指定用户root即可

yeqiang@yeqiang-MS-7B23:/data/VirtualBox VMs$ ansible -u root all -m ping

WARNING\]: Platform linux on host node-1 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information. **node-1 \| SUCCESS =\> { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" } \[WARNING\]: Platform linux on host node-3 is using the discovered Python interpreter at /usr/bin/python3.9, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information. node-3 \| SUCCESS =\> { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3.9" }, "changed": false, "ping": "pong" } \[WARNING\]: Platform linux on host node-2 is using the discovered Python interpreter at /usr/bin/python3.9, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information. node-2 \| SUCCESS =\> { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3.9" }, "changed": false, "ping": "pong" }**

相关推荐
cly11 分钟前
Ansible自动化(十一):Jinja2模板
网络·自动化·ansible
Levin__NLP_CV_AIGC7 分钟前
Ubuntu部署Dufs
linux·运维·服务器·ubuntu·ssh
cly118 分钟前
Ansible自动化(八):条件语句
运维·自动化·ansible
China_Yanhy19 分钟前
Ansible 工业级项目标准化架构指南 (V1.0)
架构·ansible
切糕师学AI21 分钟前
SSH是什么?
ssh
cly11 小时前
Ansible自动化(九):循环语句
windows·自动化·ansible
cly11 小时前
Ansible自动化(十):配置文件管理模块(lineinfile / blockinfile)
运维·自动化·ansible
gravity_w1 小时前
vscode配置SSH远程服务器
服务器·经验分享·vscode·ssh
weixin_4624462316 小时前
K8s 集群部署基础:Linux 三节点 SSH 互信(免密登录)配置指南
linux·kubernetes·ssh
m0_7381207217 小时前
应急响应——知攻善防靶场Linux-1详细应急过程
linux·运维·服务器·网络·web安全·ssh