【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" }**

相关推荐
极小狐16 小时前
GitLab 安全漏洞 CVE-2025-7739 解决方案
ci/cd·gitlab·devsecops·devops·极狐gitlab
拾心2117 小时前
【运维进阶】Ansible 角色管理
运维·ansible
phoenix098117 小时前
ansible部署lnmp-allinone
linux·运维·ansible
Lovyk1 天前
基于 Ansible 与 Jinja2 模板的 LNMP 环境及 WordPress 自动化部署实践
linux·运维·服务器·自动化·ansible
LLLLYYYRRRRRTT2 天前
WordPress (LNMP 架构) 一键部署 Playbook
linux·架构·ansible·mariadb
没有不重的名么2 天前
Tmux Xftp及Xshell的服务器使用方法
服务器·人工智能·深度学习·机器学习·ssh
拾心212 天前
【运维进阶】LNMP + WordPress 自动化部署实验
运维·自动化·ansible·mariadb
一只拉古2 天前
DevOps 基础到精通 - 宏观概览
自动化运维·devops
G_H_S_3_2 天前
【网络运维】Playbook项目实战:基于 Ansible Playbook 一键部署 LNMP 架构服务器
linux·运维·服务器·网络·ansible