gpt4 book ai didi

python-2.7 - 尝试使用 kerberos winrm 连接到 Windows winRM

转载 作者:行者123 更新时间:2023-12-02 03:06:48 32 4
gpt4 key购买 nike

所以我已经在几种不同的变体下对此进行了测试。我有一个装有 Windows 2008 R2 服务器并安装了 RHEL6 和 Python2.6 的实验室。我能够使用 ansible 作为远程进入 Windows 服务器并执行 ping 的方法(我已经遵循了有关如何执行此操作的所有说明)。我遇到无法使用 Rhel 7 和 python2.7 执行此操作的问题,但是我不确定 python 版本的差异是什么阻止了我。

我经常收到这个 hostname_override 错误...

[alebede@linuxbox]$ klist -a
Ticket cache: FILE:/tmp/krb5cc_37575
Default principal: Admin_alebede@mydomain.bla

Valid starting Expires Service principal
02/10/2017 11:30:32 02/10/2017 21:30:32 krbtgt/mydmain.bla@mydomain.bla
renew until 02/10/2017 21:30:32
Addresses: (none)
[alebede@linuxbox]$ python
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import winrm
>>> s = winrm.Session('WINDOWSBOX', auth=('admin_alebede@mydomain.bla', 'mypassword'), transport='kerberos')
>>> r = s.run_cmd('ipconfig', ['/all'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/winrm/__init__.py", line 37, in run_cmd
shell_id = self.protocol.open_shell()
File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 132, in open_shell
res = self.send_message(xmltodict.unparse(req))
File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 207, in send_message
return self.transport.send_message(message)
File "/usr/lib/python2.7/site-packages/winrm/transport.py", line 173, in send_message
self.session = self.build_session()
File "/usr/lib/python2.7/site-packages/winrm/transport.py", line 140, in build_session
sanitize_mutual_error_response=False)
TypeError: __init__() got an unexpected keyword argument 'hostname_override'

使用 ansible 它看起来像这样,相同的 hostname_override 错误:

mywinserver.mydomain.com> WINRM CONNECT: transport=ssl endpoint=https://mywinserver.mydomain.com:5986/wsman
<mywinserver.mydomain.com> WINRM CONNECTION ERROR: the specified credentials were rejected by the server
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 154, in _winrm_connect
self.shell_id = protocol.open_shell(codepage=65001) # UTF-8
File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 132, in open_shell
res = self.send_message(xmltodict.unparse(req))
File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 207, in send_message
return self.transport.send_message(message)
File "/usr/lib/python2.7/site-packages/winrm/transport.py", line 190, in send_message
raise InvalidCredentialsError("the specified credentials were rejected by the server")
InvalidCredentialsError: the specified credentials were rejected by the server

mywinserver.mydomain.com | UNREACHABLE! => {
"changed": false,
"msg": "kerberos: __init__() got an unexpected keyword argument 'hostname_override', ssl: the specified credentials were rejected by the server",
"unreachable": true
}

让我知道我还能尝试什么,同样在 Windows 2008R2 服务器上,我可以在安全事件日志中看到 linux box 正在尝试连接。不知道还有什么事发生。同样,这适用于 2 个不同的 Windows 2008R2 服务器上的 RHEL6。

最佳答案

您的 winrm 和 requests-kerberos 之间的版本可能不匹配。当我通过 pip 安装 winrm 并通过 apt 安装 requests-kerberos 时,我遇到了同样的问题。

确认您对所有安装使用的是同一个包管理器。

关于python-2.7 - 尝试使用 kerberos winrm 连接到 Windows winRM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42167673/

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