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

相关推荐
Miao121313 小时前
工程交付指标入门:如何重新掌控软件交付
大数据·运维·devops
如若1236 小时前
Ubuntu 无 sudo 安装花生壳并实现 SSH 内网穿透:Conda 环境部署、冲突排查与自动启动
linux·运维·ubuntu·ssh·内网穿透
芳草萋萋鹦鹉洲哦1 天前
【git】重新生成并添加 SSH Key(Mac)
git·macos·ssh
爱网络爱Linux1 天前
RHCSA+RHCE 10.0全新升级!红帽Ansible自动化运维
运维·自动化·ansible·rhce认证·rhel1o·linux10·rhce10
砍材农夫1 天前
运维|devops|jenkins构建分支选择及执行日志展示
运维·jenkins·devops
午安~婉1 天前
git中http与ssh连接
git·http·ssh
炸膛坦客2 天前
Git 和 GitHub:(七)将本地新建仓库与 GitHub 远程仓库关联起来(SSH)
git·ssh·github
龙智DevSecOps解决方案2 天前
Perforce Delphix测试数据管理平台:每月实现数百万次 CI/CD 运行,更快交付高质量软件
ci/cd·devops·tdm·perforce·delphix·企业级数据管理
易筋紫容2 天前
为什么做了 DevOps,你还是管不好开源依赖?
运维·开源·devops
砍材农夫3 天前
运维|devops|jenkins构建应用发布
运维·jenkins·devops