msg“:”无法通过ssh连接到主机:权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic,密码)

时间:2019-06-27 07:12:50

标签: ansible ansible-2.x ansible-inventory

当我运行“ ansible -m ping migservers -vvv”时,我收到以下错误消息。

 ansible -m ping migservers -vvv
ansible 2.8.1
  config file = /mnt/git/smart-egw-pre-production/automation-scripts/release-management-scripts/ansible.cfg
  configured module search path = [u'/home/extgw/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
Using /mnt/git/smart-egw-pre-production/automation-scripts/release-management-scripts/ansible.cfg as config file
host_list declined parsing /mnt/git/smart-egw-pre-production/automation-scripts/release-management-scripts/hosts as it did not pass it's verify_file() method
script declined parsing /mnt/git/smart-egw-pre-production/automation-scripts/release-management-scripts/hosts as it did not pass it's verify_file() method
auto declined parsing /mnt/git/smart-egw-pre-production/automation-scripts/release-management-scripts/hosts as it did not pass it's verify_file() method
Parsed /mnt/git/smart-egw-pre-production/automation-scripts/release-management-scripts/hosts inventory source with ini plugin
META: ran handlers
 [WARNING]: While constructing a mapping from /mnt/git/smart-egw-pre-production/automation-scripts/release-management-scripts/group_vars/all/var.yml, line 4, column 1,
found a duplicate dict key (authorized_user). Using last defined value only.

 [WARNING]: While constructing a mapping from /mnt/git/smart-egw-pre-production/automation-scripts/release-management-scripts/group_vars/all/var.yml, line 4, column 1,
found a duplicate dict key (dep_patches). Using last defined value only.

<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: extgw
<10.0.40.207> ESTABLISH SSH CONNECTION FOR USER: extgw
<127.0.0.1> SSH: EXEC sshpass -d10 ssh -o BatchMode=yes -o ForwardAgent=yes -o StrictHostKeyChecking=no -o StrictHostKeyChecking=no -o 'User="extgw"' -o ConnectTimeout=10 127.0.0.1 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/ansible-tmp-1561617542.31-234782308603401 `" && echo ansible-tmp-1561617542.31-234782308603401="` echo /tmp/ansible-tmp-1561617542.31-234782308603401 `" ) && sleep 0'"'"''
<10.0.40.206> ESTABLISH SSH CONNECTION FOR USER: extgw
<10.0.40.207> SSH: EXEC sshpass -d10 ssh -o BatchMode=yes -o ForwardAgent=yes -o StrictHostKeyChecking=no -o StrictHostKeyChecking=no -o 'User="extgw"' -o ConnectTimeout=10 10.0.40.207 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/ansible-tmp-1561617542.31-227856382807600 `" && echo ansible-tmp-1561617542.31-227856382807600="` echo /tmp/ansible-tmp-1561617542.31-227856382807600 `" ) && sleep 0'"'"''
<10.0.40.206> SSH: EXEC sshpass -d10 ssh -o BatchMode=yes -o ForwardAgent=yes -o StrictHostKeyChecking=no -o StrictHostKeyChecking=no -o 'User="extgw"' -o ConnectTimeout=10 10.0.40.206 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/ansible-tmp-1561617542.32-254693221799990 `" && echo ansible-tmp-1561617542.32-254693221799990="` echo /tmp/ansible-tmp-1561617542.32-254693221799990 `" ) && sleep 0'"'"''
<10.0.40.207> (255, '', 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n')
<127.0.0.1> (255, '', 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n')
10.0.40.207 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
    "unreachable": true
}
<10.0.40.206> (255, '', 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n')
10.0.40.206 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
    "unreachable": true
}
127.0.0.1 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
    "unreachable": true
}

1 个答案:

答案 0 :(得分:0)

您是否已指定remote_user选项?请参阅link并查看示例。因此,您需要指定remote_user: extgw

您可以使用剧本对其进行测试。

---
- hosts: webservers
  remote_user: root
  tasks:
    - name: test connection
      ping:
      remote_user: extgw

或尝试使用命令:

ansible all -m ping -u extgw --ask-pass