2017-08-15 41 views
0

我正在尝试使用OpenSSH和Ansible连接到我的Windows计算机。
我能够使用普通的ssh进行连接,但是当我尝试使用Ansible进行连接时,每当我改变某些东西时,我都会得到几乎相同的错误。如何使用openSSH和Ansible连接到WIndows节点?

我也试着运行Ansible为根,仍然没有

fatal: [IVU]: 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 remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: (umask 77 && mkdir -p \"` echo /tmp/ansible-tmp-1502794936.2073953-164132649383245 `\" && echo ansible-tmp-1502794936.2073953-164132649383245=\"` echo /tmp/ansible-tmp-1502794936.2073953-164132649383245 `\"), exited with result 1", "unreachable": true} 

我试图在ansible.cfg的ssh_args改变ssh_args = -O ControlMaster =没有和输出没有变化制作。

我试过在ansible.cfg改变可执行文件到C:/Windows/System32/cmd.exe,我得到了同样的错误

我试图改变remote_dir =的/ tmp /和依然没有。

我ansible库存:

[IVU] 
IVU ansible_host=**IP** 

[IVU:vars] 
ansible_port=22 
ansible_user=**user** 
ansible_ssh_pass=**pass** 
ansible_ssh_private_key_file=** Keyfile ** 

好像它的失败之前,即使在运行任何任务,但是从Windows计算机上安装openssh的日志,我看不出有什么区别时ansible连接到它,当我ssh到它。

3724 09:27:38:720 error: Couldn't create pid file "C:\\Program Files\\OpenSSH\\sshd.pid": Permission denied 
3724 09:27:41:376 Accepted publickey for **User** from **IP** port 42700 ssh2: RSA SHA256:clNmiKxygl/TLEb5Ob4lZs6JqztoQyxOsjMoHQ2HYgo 
3724 09:27:58:533 Received disconnect from **IP** port 42700:11: disconnected by user 
3724 09:27:58:533 Disconnected from user **User** **IP** port 42700 
3360 09:28:41:398 error: Couldn't create pid file "C:\\Program Files\\OpenSSH\\sshd.pid": Permission denied 
3360 09:28:41:616 Accepted publickey for **User** from **IP** port 42704 ssh2: RSA SHA256:clNmiKxygl/TLEb5Ob4lZs6JqztoQyxOsjMoHQ2HYgo 
3360 09:28:41:741 Received disconnect from **IP** port 42704:11: disconnected by user 
3360 09:28:41:741 Disconnected from user **User** **IP** port 42704 

9:27是当我用ssh连接时,而9:28是当连接时。

有没有什么我想我需要改变Ansible才能在windows上使用openSSH?

回答

0

我想通过使用反向ssh隧道的解决方案。

我放弃了试图在Windows上使用ssh ansible模块的想法,因为除非您有Windows 10更新,否则Windows根本无法正常使用它。我决定改用winrm ansible模块。

我所做的是我通过使用命令打开一个反向的SSH隧道连接的Windows计算机运行Ansible计算机:

ssh -p5983 -R 5982:localhost:5986 **my_user**@**my_ip** 

对于我而言,我不得不端口转发,因为我的计算机是在一个单独的VLAN比windows计算机
然后在Ansible予指定的主机在端口5982.

这是一个关于一样好与OpenSSH和窗口,工作时的解决方案的本地主机至少直至Ansible支持Windows的OpenSSH 。