ssh - 由于“无法通过 ssh 连接到主机”,我无法执行我的 ansible playbook
问题描述
我可以通过 ssh 连接我的主节点,但是当我启动我的 ansible playbook 时,它说“无法通过 ssh 连接到主机”。我不懂为什么。有人可以帮我解决这个问题。
[ansadmin@ip-172-31-52-198 ssh]$ cd /home/ansadmin/.ssh/
[ansadmin@ip-172-31-52-198 .ssh]$ ssh -i /home/ansadmin/.ssh/id_rsa2 opc@132.145.209.167
Oracle Linux Server 7.8
Last login: Tue Jun 30 16:42:47 2020 from 132.145.169.136
[opc@oke-c3doyjxha4g-nrtgmbsgq3d-srmrh4en3ga-2 ~]$ exit
logout
Connection to 132.145.209.167 closed.
[ansadmin@ip-172-31-52-198 .ssh]$ cd /opt/kubernetes/
[ansadmin@ip-172-31-52-198 kubernetes]$ ansible-playbook -i hosts kubernetes-valaxy-deployment.yml -vvv
ansible-playbook 2.9.9
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ansadmin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
executable location = /usr/local/bin/ansible-playbook
python version = 2.7.18 (default, May 7 2020, 09:20:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /opt/kubernetes/hosts as it did not pass its verify_file() method
script declined parsing /opt/kubernetes/hosts as it did not pass its verify_file() method
auto declined parsing /opt/kubernetes/hosts as it did not pass its verify_file() method
[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still be user configurable on deprecation. This feature
will be removed in version 2.10. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
Parsed /opt/kubernetes/hosts inventory source with ini plugin
PLAYBOOK: kubernetes-valaxy-deployment.yml *****************************************************************************************************************************************************************
1 plays in kubernetes-valaxy-deployment.yml
PLAY [Create pods using deployment] ************************************************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************************************************************************
task path: /opt/kubernetes/kubernetes-valaxy-deployment.yml:3
<132.145.209.167> ESTABLISH SSH CONNECTION FOR USER: root
<132.145.209.167> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/home/ansadmin/.ansible/cp/b09c8a513c 132.145.209.167 '/bin/sh -c '"'"'echo ~root && sleep 0'"'"''
<132.145.209.167> (255, '', 'Oracle Linux Server 7.8\nPermission denied (publickey).\r\n')
fatal: [132.145.209.167]: UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Oracle Linux Server 7.8\nPermission denied (publickey).",
"unreachable": true
}
PLAY RECAP *************************************************************************************************************************************************************************************************
132.145.209.167 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
[ansadmin@ip-172-31-52-198 kubernetes]$ cat /etc/ansible/ansible.cfg
[defaults]
privatekeyfile = /home/ansadmin/.ssh/id_rsa2
解决方案
推荐阅读
- ios - Core Data 使用 Canvas 预览的要求是什么 - SwiftUI
- c# - Newtonsoft.Json - 反序列化自定义类型时抛出 DeserializeObject:将值“somestring”转换为类型 CustomType 时出错
- sql - 在数据库“天气”上执行 SQL 查询时出错:“(”附近:语法错误
- c# - .NET Core/5 IConfiguration 在 Raspberry Pi 4 4GB 上的 Ubuntu 20.10 x64 上不起作用
- c# - 如何使用 C# 在 Excel 上定位特定工作表
- c# - 无法加载文件或程序集 Microsoft.Extensions.DependencyInjection.Abstractions,版本 = 5.0.0.0
- bash - 如果脚本文件具有 CRLF 行结尾,则将 U+F00D 字符附加到文件名
- javascript - 如何在 iOS 版 Chrome 中使用 Web-NFC?
- python - tf.keras.utils.to_categorical 是否在多个输入中保持一致?
- android - Android Studio 仅在第二次运行时更新更改