ansible SSH连接失败 [英] ansible SSH connection fail

查看:9977
本文介绍了ansible SSH连接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在多个服务器上运行ansible角色,但我收到一个错误:

I'm trying to run ansible role on multiple servers, but i get an error:


fatal:[192.168.0.10] :不可信! => {changed:false,msg:
无法通过ssh连接到主机,unreachable:true}

fatal: [192.168.0.10]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}

我的/ etc / ansible / hosts文件如下所示:

My /etc/ansible/hosts file looks like this:

192.168.0.10 ansible_sudo_pass='passphrase' ansible_ssh_user=user
192.168.0.11 ansible_sudo_pass='passphrase' ansible_ssh_user=user
192.168.0.12 ansible_sudo_pass='passphrase' ansible_ssh_user=user

我不知道发生了什么 - 一切都很好 - 我可以通过SSH登录,但是ansible ping会返回相同的错误。

I have no idea what's going on - everything looks fine - I can login via SSH, but ansible ping returns the same error.

从详细执行日志:


< 192.168.0.10>为用户建立SSH连接:user< 192.168。 0.10>
SSH:EXEC ssh -C -vvv -o ControlMaster = auto -o ControlPersist = 60s -o
KbdInteractiveAuthentication = no -o
PreferredAuthentications = gssapi-with-mic,gssapi-keyex ,hostbased,publickey
-o PasswordAuthentication = no -o User = user -o ConnectTimeout = 10 -o ControlPath = / root / .ansible / cp / ansible-ssh-%h-%p-%r 192.168.0.10
'/ bin / sh -c'''(umask 22&& mkdir -p echo
$ HOME / .ansible / tmp / ansible-tmp-1463151813.31-156630225033829
&&
echo echo
$ HOME / .ansible / tmp / ansible-tmp-1463151813.31-156630225033829

)'' '

<192.168.0.10> ESTABLISH SSH CONNECTION FOR USER: user <192.168.0.10> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.0.10 '/bin/sh -c '"'"'( umask 22 && mkdir -p "echo $HOME/.ansible/tmp/ansible-tmp-1463151813.31-156630225033829" && echo "echo $HOME/.ansible/tmp/ansible-tmp-1463151813.31-156630225033829" )'"'"''

你能帮我吗?如果我必须在本地模式下使用ansible(-c local),那么它是没用的。

Can you help me somehow? If I have to use ansible in local mode (-c local), then it's useless.

我试图删除ansible_sudo_pass和ansible_ssh_user,但它did'nt帮助。

I've tried to delete ansible_sudo_pass and ansible_ssh_user, but it did'nt help.

推荐答案

您还需要更改 ansible_ssh_pass ,例如我在我的库存文件中使用这个:

You need to change the ansible_ssh_pass as well or ssh key, for example I am using this in my inventory file:

192.168.33.100 ansible_ssh_pass=vagrant ansible_ssh_user=vagrant

之后,我可以连接到远程主机:

After that I can connect to the remote host:

ansible all -i tests -m ping

192.168.33.100 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}


b $ b

希望能帮助你。

Hope that help you.

这篇关于ansible SSH连接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆