gpt4 book ai didi

windows - 通过ssh ping Windows时如何修复 “Unreachable”?

转载 作者:行者123 更新时间:2023-12-02 14:13:24 35 4
gpt4 key购买 nike

我正在尝试将Ansible与ssh结合使用以与Windows计算机交互

我已经在Windows机器上成功安装了OpenSSH,这意味着我可以使用以下命令从linux连接到Windows:

 ssh username@ipAdresse

我尝试使用许多版本的ansible(2.6、2.7.12、2.7.14、2.8.5和2.8.6),并且我始终测试是否可以通过此行ping其他Linux机器(它可以正常工作):
ansible linux -m ping

有我的主机文件
[windows]
192.***.***.***

[linux]
192.***.***.***

[all:vars]
ansible_connection=ssh
ansible_user=root

[windows:vars]
ansible_ssh_pass=*******
remote_tmp=C:\Users\root\AppData\Local\Temp\
become_method=runas


冗长存在错误:
[root@oel76-template ~]# ansible windows -m win_ping -vvv

ansible 2.8.6
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Aug 7 2019, 08:19:52) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39.0.1)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
META: ran handlers
<192.***.***.***> ESTABLISH SSH CONNECTION FOR USER: root
<192.***.***.***> SSH: EXEC sshpass -d8 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/91df1ca379 192.168.46.99 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo C:/Users/root/AppData/Local/Temp/ansible-tmp-1571839448.66-279092717123794 `" && echo ansible-tmp-1571839448.66-279092717123794="` echo C:/Users/root/AppData/Local/Temp/ansible-tmp-1571839448.66-279092717123794 `" ) && sleep 0'"'"''
<192.***.***.***> (1, '', 'The system cannot find the path specified.\r\n')
<192.***.***.***> Failed to connect to the host via ssh: The system cannot find the path specified.

192.***.***.*** | UNREACHABLE! => {
"changed": false,
"msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo C:/Users/root/AppData/Local/Temp/ansible-tmp-1571839448.66-279092717123794 `\" && echo ansible-tmp-1571839448.66-279092717123794=\"` echo C:/Users/root/AppData/Local/Temp/ansible-tmp-1571839448.66-279092717123794 `\" ), exited with result 1",
"unreachable": true
}


我不知道自己在做什么错,我也尝试在ansible.cfg中更改remote_tmp,但仅此而已。

remote_tmp = C的实际值:/ Users / root / AppData / Local / Temp

任何的想法 ?

最佳答案

要将SSH用作与Windows主机的连接(从Ansible 2.8开始),请在 list 中设置以下变量:

  • ansible_connection = ssh
  • ansible_shell_type = cmd / powershell(设置cmd或powershell两者都不设置)

  • 最后, list 文件:
    [windows]
    192.***.***.***

    [all:vars]
    ansible_connection=ssh
    ansible_user=root

    [windows:vars]
    ansible_password='*******'
    ansible_shell_type=cmd

    注意变量 ansible_password 。对于带有特殊字符的密码,请使用单引号。

    关于windows - 通过ssh ping Windows时如何修复 “Unreachable”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58525753/

    35 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com