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

相关推荐
信创DevOps先锋3 小时前
Gitee DevOps平台:本土化创新如何重塑企业研发效能图谱
运维·gitee·devops
染夕陌木4 小时前
极简教程:GitLab 上配置 SSH Key(附常见问题解决)
运维·ssh·gitlab
rabbit_pro4 小时前
IDEA保存SSH会话信息
java·ssh·intellij-idea
SilentSamsara13 小时前
SSH 远程管理:密钥登录 + 隧道转发,一次性配置好
linux·运维·服务器·ubuntu·centos·ssh
向宇it19 小时前
关闭SSH密码登录,SSH 如何使用公钥密钥登录服务器(解决服务器经常被攻击问题)
服务器·网络·ssh
亚空间仓鼠20 小时前
Ansible之Playbook(三):变量应用
java·前端·ansible
信创DevOps先锋1 天前
Gitee DevOps:构筑国产化数字基座,赋能企业信创转型
运维·gitee·devops
盘古信息IMS1 天前
2026年WMS系统选型指南:制造企业如何构建高度适配的智能仓储中枢?
运维·制造·devops
亚空间仓鼠1 天前
Ansible之Playbook(二):模块大全
ansible
Chuncheng's blog1 天前
Mac ssh连接无操作自动断开异常
运维·macos·ssh