当前位置:   article > 正文

Ansible 报错 Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-w...

ansible copy报错 permission denied: b'/etc/ansible/.cluster/ssl/admin-key.pe

[root@k8s-master ~]# ansible-playbook /etc/ansible/copy.yml

PLAY [webservers] **************************************************************************************************************************************************************************************

TASK [copy files] **************************************************************************************************************************************************************************************
failed: [192.168.10.149] (item={u'dest': u'/root/copytest4.txt', u'src': u'/root/copytest4.txt'}) => {"ansible_loop_var": "item", "item": {"dest": "/root/copytest4.txt", "src": "/root/copytest4.txt"}, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}
fatal: [192.168.10.149]: UNREACHABLE! => {"changed": false, "msg": "All items completed", "results": [{"ansible_loop_var": "item", "item": {"dest": "/root/copytest4.txt", "src": "/root/copytest4.txt"}, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}]}
failed: [192.168.10.150] (item={u'dest': u'/root/copytest4.txt', u'src': u'/root/copytest4.txt'}) => {"ansible_loop_var": "item", "item": {"dest": "/root/copytest4.txt", "src": "/root/copytest4.txt"}, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}
failed: [192.168.10.148] (item={u'dest': u'/root/copytest4.txt', u'src': u'/root/copytest4.txt'}) => {"ansible_loop_var": "item", "item": {"dest": "/root/copytest4.txt", "src": "/root/copytest4.txt"}, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}
fatal: [192.168.10.150]: UNREACHABLE! => {"changed": false, "msg": "All items completed", "results": [{"ansible_loop_var": "item", "item": {"dest": "/root/copytest4.txt", "src": "/root/copytest4.txt"}, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}]}
fatal: [192.168.10.148]: UNREACHABLE! => {"changed": false, "msg": "All items completed", "results": [{"ansible_loop_var": "item", "item": {"dest": "/root/copytest4.txt", "src": "/root/copytest4.txt"}, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}]}

 看到这个报错脑袋大,直到翻阅官网的github 找到解决

Failed to connect to the host via ssh: Permission denied (publickey,password) · Issue #19584 · ansible/ansible · GitHub

[root@k8s-master ~]# ansible all -m ping --ask-pass
SSH password:
192.168.10.148 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.10.150 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.10.149 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}

  1. [root@k8s-master ~]# cat /etc/ansible/zip.yml
  2. ---
  3. - hosts: webservers
  4. gather_facts: no
  5. become: yes
  6. become_method: sudo
  7. tasks:
  8. - name: "copy files"
  9. copy:
  10. src: "{{ item.src }}"
  11. dest: "{{ item.dest }}"
  12. owner: root
  13. group: root
  14. mode: 755
  15. with_items:
  16. - {src: "/root/copytest4.txt", dest: "/root/copytest4.txt" }
  17. - {src: "/root/dist.zip", dest: "/root/dist.zip" }
  18. - name: "unzip files"
  19. shell: unzip /root/dist.zip -d /tmp
  1. root@k8s-master ~]# cat /etc/ansible/hosts
  2. # This is the default ansible 'hosts' file.
  3. #
  4. # It should live in /etc/ansible/hosts
  5. #
  6. # - Comments begin with the '#' character
  7. # - Blank lines are ignored
  8. # - Groups of hosts are delimited by [header] elements
  9. # - You can enter hostnames or ip addresses
  10. # - A hostname/ip can be a member of multiple groups
  11. # Ex 1: Ungrouped hosts, specify before any group headers.
  12. ## green.example.com
  13. ## blue.example.com
  14. ## 192.168.100.1
  15. ## 192.168.100.10
  16. # Ex 2: A collection of hosts belonging to the 'webservers' group
  17. [webservers]
  18. ## alpha.example.org
  19. ## beta.example.org
  20. 192.168.10.149
  21. 192.168.10.148
  22. 192.168.10.150
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/144583
推荐阅读
相关标签
  

闽ICP备14008679号