当将 ping 与 ansible 一起使用时,它会返回“无法执行命令行和远程命令。”

发布于 2025-01-18 09:25:32 字数 2799 浏览 0 评论 0原文

我希望使用Bastian服务器使用ProxyJump,可以使用.ssh/config用于所有SSH连接。我有一个非常简单的库存文件。

[apps]
app[998:999]

运行以下命令时,

ansible all -i ansible.cfg -m ping -vvvv

我会得到以下输出

<app999> (255, b'', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 47: Applying options for app???\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_addr: could not resolve name app999 as address: Name or service not known\r\ndebug3: resolve_canonicalize: attempting "app999" => "app999.vetdrive.io."\r\ndebug1: Canonicalized hostname "app999" => "app999.vetdrive.io"\r\ndebug1: Re-reading configuration after hostname canonicalisation\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 51: Applying options for app???.vetdrive.io\r\ndebug1: /home/hamzaafridi/.ssh/config line 55: Applying options for *.vetdrive.io\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -vvv -W \'[%h]:%p\' bast.vetdrive.io\r\nCannot execute command-line and remote command.\r\n')
app999 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 47: Applying options for app???\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_addr: could not resolve name app999 as address: Name or service not known\r\ndebug3: resolve_canonicalize: attempting \"app999\" => \"app999.vetdrive.io.\"\r\ndebug1: Canonicalized hostname \"app999\" => \"app999.vetdrive.io\"\r\ndebug1: Re-reading configuration after hostname canonicalisation\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 51: Applying options for app???.vetdrive.io\r\ndebug1: /home/hamzaafridi/.ssh/config line 55: Applying options for *.vetdrive.io\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -vvv -W '[%h]:%p' bast.vetdrive.io\r\nCannot execute command-line and remote command.",
    "unreachable": true
}

,我不确定我在做什么错。我可以简单地做SSH App999即可访问服务器,并且工作正常。

任何帮助都将受到赞赏。

谢谢

I want ansible to use .ssh/config for all the ssh connection as we are using proxyJump using bastian servers. I have a very simple inventory file.

[apps]
app[998:999]

when running the following command

ansible all -i ansible.cfg -m ping -vvvv

I get the following output

<app999> (255, b'', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 47: Applying options for app???\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_addr: could not resolve name app999 as address: Name or service not known\r\ndebug3: resolve_canonicalize: attempting "app999" => "app999.vetdrive.io."\r\ndebug1: Canonicalized hostname "app999" => "app999.vetdrive.io"\r\ndebug1: Re-reading configuration after hostname canonicalisation\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 51: Applying options for app???.vetdrive.io\r\ndebug1: /home/hamzaafridi/.ssh/config line 55: Applying options for *.vetdrive.io\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -vvv -W \'[%h]:%p\' bast.vetdrive.io\r\nCannot execute command-line and remote command.\r\n')
app999 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 47: Applying options for app???\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_addr: could not resolve name app999 as address: Name or service not known\r\ndebug3: resolve_canonicalize: attempting \"app999\" => \"app999.vetdrive.io.\"\r\ndebug1: Canonicalized hostname \"app999\" => \"app999.vetdrive.io\"\r\ndebug1: Re-reading configuration after hostname canonicalisation\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 51: Applying options for app???.vetdrive.io\r\ndebug1: /home/hamzaafridi/.ssh/config line 55: Applying options for *.vetdrive.io\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -vvv -W '[%h]:%p' bast.vetdrive.io\r\nCannot execute command-line and remote command.",
    "unreachable": true
}

I am not sure what I doing wrong. I can simply do ssh app999 to access the server and it's working perfectly fine.

Any help is appreciated.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零崎曲识 2025-01-25 09:25:33

问题是.ssh/config I具有remoteCommand byob,该>与Ansible无效。

The issue was with .ssh/config I had RemoteCommand byob which doesn't work with ansible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文