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

相关推荐
あ-29 分钟前
企业 DevOps + 协同办公 + 可观测性 + 网络基础设施平台
运维·网络·devops
JeJe同学2 小时前
Linux远程服务器网络访问优化:使用SSH反向端口转发共享本地HTTP代理
服务器·网络·ssh
idealzouhu4 小时前
深入 Git 账户模型:从提交身份到 SSH 多账户隔离的完整实践
git·ssh
就叫飞六吧1 天前
SSH 本地端口转发:用 localhost 访问远程服务
运维·ssh
极小狐1 天前
干掉流水线里的长期密钥:用 OIDC 让 CI/CD 与云以临时凭证对接
microsoft·ci/cd·gitlab·devops·ci·cd·oidc
一只积极向上的小咸鱼2 天前
Codex Remote SSH / Dev Container 无限转圈与 GPT-6 可用问题排查总结
运维·gpt·ssh
极小狐2 天前
CI 流水线提速实战:缓存设计与依赖代理的工程实践
缓存·ci/cd·gitlab·devops
风景的人生2 天前
Linux虚拟机网络故障排查与解决方案
运维·网络·ssh
吴佳浩 Alben2 天前
构建企业级 DevOps 排错 Agent:从日志告警到自动化修复 PR
大数据·人工智能·语言模型·架构·自动化·ai编程·devops
harmony&2 天前
DevOps进阶:SonarQube 代码审计与 Harbor 镜像仓库实战
运维·devops