2017-09-28 3 views
0

J'ai un maître et un esclave.
Je peux me connecter via ssh du maître à l'esclave.
Ansible ne peut pas connecter du maître à l'esclave.Ansible dit "Permission refusée (clé publique, mot de passe)"

Question: Qu'est-ce que je fais de mal, de sorte que Ansible ne peut pas se connecter, mais ssh peut?

connexion réussie du maître à l'esclave via ssh

[email protected]:~$ ssh slave.local 
Enter passphrase for key '/home/vagrant/.ssh/id_rsa': 
[email protected]'s password: 
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-87-generic x86_64) 

* Documentation: https://help.ubuntu.com 
* Management:  https://landscape.canonical.com 
* Support:  https://ubuntu.com/advantage 

17 packages can be updated. 
9 updates are security updates. 


---------------------------------------------------------------- 
    Ubuntu 16.04.3 LTS       built 2017-09-08 
---------------------------------------------------------------- 
Last login: Thu Sep 28 15:20:21 2017 from 10.0.0.10 
[email protected]:~$ 

erreur Ansible: "Permission refusée (publickey, mot de passe)"

[email protected]:~$ ansible all -m ping -u vagrant 
The authenticity of host 'slave.local (10.0.0.11)' can't be established. 
ECDSA key fingerprint is SHA256:tRGlinvTj/c2gpTayZ/mYzyWbs63s+BUX81TdKJ+0jQ. 
Are you sure you want to continue connecting (yes/no)? yes 
Enter passphrase for key '/home/vagrant/.ssh/id_rsa': 

slave.local | UNREACHABLE! => { 
"changed": false, 
"msg": "Failed to connect to the host via ssh: Warning: Permanently added 'slave.local' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,password).\r\n", 
"unreachable": true 
} 

Ceci est mon fichier hosts

[email protected]:~$ cat /etc/ansible/hosts 
[web] 
slave.local 
+2

Exécuter avec 'interrupteur -vvv' et voyez ce qui ne va pas avec la commande ssh. –

+0

Est-ce que vous essayez d'entrer ssh dans [email protected]? Votre exemple de manuel ssh se connecte à [email protected] – Rickkwa

+0

@Konstantin malheureusement vvvv ne fournit aucune information supplémentaire. mais je l'ai ajouté ci-dessus – Skip

Répondre

0

La solution est d'ajouter la clé privée au format OpenSSH au fichier /home/vagrant/.ssh/id_rsa
C'est là ansible est à la recherche de la clé.

Ce que je pourrait trouver, en commençant ansible en mode verbose, en utilisant la touche "-vvvv"

ansible all -m ping -u vagrant -vvvv 

La sortie verbeuse était

10.0.0.11 | UNREACHABLE! => { 
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket \"/home/vagrant/.ansible/cp/a72f4dc97e\" does not exist\r\ndebug2: resolving \"10.0.0.11\" port 22\r\ndebug2: ssh_connect_direct: needpriv 0\r\ndebug1: Connecting to 10.0.0.11 [10.0.0.11] port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: fd 3 clearing O_NONBLOCK\r\ndebug1: Connection established.\r\ndebug3: timeout: 10000 ms remain after connect\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /home/vagrant/.ssh/id_rsa type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file ...