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

相关推荐
云攀登者-望正茂3 小时前
Azure 应用的托管身份与服务主体
azure·devops
冼紫菜7 小时前
如何在 CentOS 7 虚拟机上配置静态 IP 地址并保持重启后 SSH 连接
linux·开发语言·centos·ssh
一直奔跑在路上7 小时前
【Ansible】基于windows主机,采用NTLM+HTTPS 认证部署
windows·https·ansible
遇见火星15 小时前
Ansible模块——从控制节点向目标主机复制文件!
java·服务器·ansible
czhc114007566316 小时前
Linux513 rsync本地传输 跨设备传输 一
ssh
Willis_m1 天前
Linux 服务器用 SSH 拉取多个 Git 工程
linux·服务器·git·ssh
胖大和尚1 天前
Termius ssh连接服务器 vim打开的文件无法复制问题
服务器·ssh·vim
大米☋2 天前
GitLab搭建与使用(SSH和Docker)两种方式
docker·ssh·gitlab
Huazzi.2 天前
使用SSH协议克隆详细步骤
linux·运维·学习·ssh·编程
lisw052 天前
网络化:DevOps 工程的必要基础(Networking: The Essential Foundation for DevOps Engineering)
网络·devops