通过terminalSSH成功​​,但通过Ansible相同的SSH连接在同一台机器上失败?

任何人都可以阐明为什么发生这种情况?

我用用户basicuserlogin到机器A,客户端。 当我尝试在机器B(服务器机器上,作为远程​​用户)上运行一个可靠的剧本。

  • 1)我的私钥/公钥DEFINIELY匹配,在客户端A(以basicuser身份)工作的“ssh user @ serverB”显而易见 – 安全和SSH都指向相同的私钥
  • 2)我〜/ .ssh / known_hosts不过时
  • 3)my〜/ .ssh和〜/ .ssh / *权限是正确的(分别由basicuser,chmod 700拥有)
  • 4)我的hosts.ini文件包含所需的“ansible_ssh_user = remoteuser ansible_ssh_private_key_file =〜/ .ssh / id_rsa”(并且格式正确)

我知道id_rsa匹配/home/remoteuser/.ssh中机器B的“authorized_keys”文件中唯一的条目。

这里是从客户端A通过terminal的SSH:

basicuser@serverA:~$ ssh remoteuser@serverB Enter passphrase for key '/home/basicuser/.ssh/id_rsa': Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Wed Jul 16 23:38:41 2014 from xxx.xxx.xxx.xxx remoteuser@serverB:~$ 

下面是当我运行一个完整的剧本时发生的事情: http : //pastebin.com/6wXgp3dd

我把它放在pastebin上,因为它的输出相当多。 然而,让我觉得奇怪的是,这有点接近尾声:

 debug2: key: /home/basicuser/.ssh/id_rsa ((nil)) debug1: Authentications that can continue: publickey debug3: start over, passed a different list publickey debug3: preferred gssapi-with-mic,gssapi-keyex,hostbased,publickey debug3: authmethod_lookup publickey debug3: remaining preferred: ,gssapi-keyex,hostbased,publickey debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Trying private key: /home/basicuser/.ssh/id_rsa debug1: key_parse_private_pem: PEM_read_PrivateKey failed debug1: read PEM private key done: type <unknown> debug1: read PEM private key done: type RSA debug3: sign_and_send_pubkey: RSA ed:bb:6d:4e:e3:7a:54:0a:19:f6:ee:1c:d0:f2:1b:3f debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey debug2: we did not send a packet, disable method debug1: No more authentication methods to try. Permission denied (publickey). 

现在我已经花了三天左右的时间了。 为什么地球上的terminalSSH工作,但是ansible的失败?

我在/ etc / ssh / ssh_config中没有任何覆盖 – 我需要任何?

经过多次调整和咖啡,我找出了我做错了什么。 我有“ansible_ssh_user”参数重复我的hosts.ini和我的部署文件之间 – 但不是私钥参数。 这就是说,我在我的SSH密钥没有密码! 我不得不多次input“WAY”这个短语。

感谢有见识的人