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

相关推荐
智能运维指南1 小时前
破解信创改造痛点:国产DevOps平台选型的核心逻辑与实践路径
devops·devops平台·devops系统·devops厂商·研发效能平台
翰德恩咨询1 小时前
敏捷咨询实战:如何让DevOps从理念到高效落地
敏捷开发·devops
闫记康8 小时前
linux配置ssh
linux·运维·服务器·学习·ssh
_运维那些事儿13 小时前
GitLabCI/CD语法
linux·服务器·git·ci/cd·gitlab·运维开发·devops
_运维那些事儿13 小时前
GitLab&Jenkins
运维·ci/cd·gitlab·jenkins·devops
xzl0413 小时前
新IP的 SSH 指纹添加到 known_hosts 文件
网络协议·tcp/ip·ssh
qinyia1 天前
如何安全删除通过 Git Clone 下载的所有仓库目录
运维·数据库·人工智能·git·mysql·ssh
never_go_away1 天前
ssh 特定用户特定端口
运维·ssh
天才少女爱迪生1 天前
在 VSCode 中配置 SSH 并实现 X11 转发:服务器程序远程桌面显示
ide·vscode·ssh
zdIdealism1 天前
cnPuTTY CAC 0.83 Update 1—PuTTY CAC 0.83中文版本简单说明~~
linux·运维·服务器·ssh·putty·putty-cac