【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 小时前
ansible 使用更高版本的python版本
ansible
IT成长日记1 小时前
【自动化运维神器Ansible】Ansible常用模块之hostname模块详解
运维·自动化·ansible·hostname·常用模块
维尔切5 小时前
Linux中ssh远程登录原理与配置
android·linux·ssh
IT成长日记7 小时前
【自动化运维神器Ansible】Ansible常用模块之cron模块详解
运维·自动化·ansible·cron·cron模块·常用模块
Insist7537 小时前
linux系统----Ansible中的playbook简单应用
ansible
雪域迷影11 小时前
Ubuntu22.04中生成gitee码云的ssh-key并添加到gitee网站上
运维·gitee·ssh·ubuntu22.04
johnny23311 小时前
Jaeger理论、实战、问题记录
devops
leafpipi13 小时前
【机器学习】pycharm使用SSH SFTP 远程连接 ubuntu服务器 进行开发+调试+数据训练
服务器·学习·算法·ubuntu·pycharm·ssh
❀͜͡傀儡师14 小时前
修改CentOS的SSH登录端口(22端口)
linux·centos·ssh
SpiderPex1 天前
GitHub下载项目完整配置SSH步骤详解
运维·ssh·github