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

相关推荐
学Linux的语莫4 小时前
Ansible使用简介和基础使用
linux·运维·服务器·nginx·云计算·ansible
学Linux的语莫12 小时前
Ansible Playbook剧本用法
linux·服务器·云计算·ansible
Nightwish513 小时前
ansible操作随记(一)
ansible
qq_3831398417 小时前
ansible playbook安装nacos
ansible
Zhijun.li@Studio2 天前
Mac下的vscode远程ssh免密码登录
vscode·macos·ssh
爱串门的小马驹2 天前
git,ssh免密公钥配置,gitee为例,GitHub,gitlab同理
运维·git·ssh
XMYX-03 天前
深入理解 DevOps:从理念到实践
运维·devops
cronaldo913 天前
研发效能DevOps: Vite 使用 Axios 实现数据双向绑定
vue.js·vue·devops
联蔚盘云3 天前
阿里云 DevOps 资源安全扫描实践
安全·阿里云·devops
落非3 天前
kubesphere问题处理:devops
运维·devops