web-dev-qa-db-fra.com

ESSIBLE - Erreur SSH: Les données n'ont pas pu être envoyées à l'hôte distant

J'essaie d'utiliser Ansible 2.7.7 Pour gérer Ubuntu 16.04 cloud image Mais quand j'essaie de faire une connexion, je reçois une erreur:

SSH Error: data could not be sent to remote Host "192.168.111.11". Make sure this Host can be reached over ssh

Si je publie la commande ssh [email protected] Sur l'hôte ansible, je peux me connecter au serveur cible sans problèmes. Je peux aussi Sudo là-bas sans invite de mot de passe.

Si vous envisagez des journaux de la machine cible, je vois que l'ansite connecté avec succès à la machine:

Feb 20 11:44:51 ubuntu sshd[2870]: Accepted publickey for ubuntu from 192.168.111.111 port 56236 ssh2: RSA SHA256:yI...
Feb 20 11:44:51 ubuntu sshd[2870]: pam_unix(sshd:session): session opened for user ubuntu by (uid=0)
Feb 20 11:44:51 ubuntu systemd-logind[1090]: New session 13 of user ubuntu.
Feb 20 11:44:51 ubuntu Sudo:   ubuntu : TTY=unknown ; PWD=/home/ubuntu ; USER=root ; COMMAND=/bin/sh -c echo BECOME-SUCCESS-kldfjkldjhjljkl; /usr/bin/python
Feb 20 11:44:51 ubuntu Sudo: pam_unix(Sudo:session): session opened for user root by (uid=0)
Feb 20 11:44:51 ubuntu Sudo: pam_unix(Sudo:session): session closed for user root

Sortie verbose:

ansible-playbook -i inventory default.yaml -vvv
ansible-playbook 2.7.7
  config file = /home/admin/ansible/ansible.cfg
  configured module search path = [u'/home/admin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/admin/ansible/ansible-env/local/lib/python2.7/site-packages/ansible
  executable location = /home/admin/ansible/ansible-env/bin/ansible-playbook
  python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0 20160609]
Using /home/admin/ansible/ansible.cfg as config file
/home/admin/ansible/inventory did not meet Host_list requirements, check plugin documentation if this is unexpected
/home/admin/ansible/inventory did not meet script requirements, check plugin documentation if this is unexpected
Parsed /home/admin/ansible/inventory inventory source with ini plugin

PLAYBOOK: default.yaml *******************************************************************************************************************************************************************************************************************
1 plays in default.yaml

PLAY [default] ***************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************
task path: /home/admin/ansible/default.yaml:3
Using module file /home/admin/ansible/ansible-env/local/lib/python2.7/site-packages/ansible/modules/system/setup.py
<192.168.111.11> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<192.168.111.11> 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=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/a9e60c69b0 192.168.111.11 '/bin/sh -c '"'"'Sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-tenlfcstwmojszikegdyatixrzpwqwah; /usr/bin/python'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
fatal: [192.168.111.11]: UNREACHABLE! => {
    "changed": false,
    "unreachable": true
}

MSG:

SSH Error: data could not be sent to remote Host "192.168.111.11". Make sure this Host can be reached over ssh

Qu'est-ce qui pourrait causer cette question?

2
Madoc Comadrin

Etepte mon système cible requis tty lorsque vous utilisez Sudo.

J'ai pu faire de la connexion à mon commentaire de cette ligne de ansible.cfg:

pipelining = True

Une autre option aurait été désactivée par le réglage requiretty du fichier sudoer.

2
Madoc Comadrin

Élaborer plus sur @MICHAEL HAMPTON Commentaire et. Ansible masque l'erreur SSH.

Dans mon cas, la vraie erreur, montrée avec le niveau verbeux de - VVvv était: Host key verification failed. et j'ai trouvé la solution ici:

https://unix.stackexchange.com/questions/416166/cant-establish-ssh-connection-debug1-read-passphrase-cant-open-dev-tty-n#answer-416186

Fondamentalement, fournissez l'option SSH: -o StrictHostKeyChecking=no

0
davidmpaz