2017-02-10 224 views
2

所以我已经测试了几种不同的变化。我有一个安装了Windows 2008 R2服务器和RHEL6和Python2.6的实验室。我能够使用ansible作为手段远程进入Windows服务器并执行ping(我已遵循所有关于如何执行此操作的说明)。 我得到的问题不能用Rhel 7和python2.7来完成,但是我不确定python版本的区别是什么阻止了我。试图连接到Windows winRM使用Kerberos winrm

我不断地得到这个hostname_override错误...

[[email protected]]$ klist -a 
Ticket cache: FILE:/tmp/krb5cc_37575 
Default principal: [email protected] 

Valid starting  Expires    Service principal 
02/10/2017 11:30:32 02/10/2017 21:30:32 krbtgt/[email protected] 
    renew until 02/10/2017 21:30:32 
    Addresses: (none) 
[[email protected]]$ 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=('[email protected]',   '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盒正在尝试连接安全事件日志。不知道还有什么事情发生。再次,这可以在RHEL6中的2个不同的Windows 2008R2服务器上运行。

+0

可以对hostname_override是什么意思做一些评论?我可以在DNS中完全解决所有问题,我的Linux服务器作为我的Windows服务器在域中。我对所有的东西都拥有完全的权限,并且对所有的东西都是远程的......这个失败与什么有关? –

回答

0

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

确认您对所有安装使用单个软件包管理器。

+0

你可能是对的。但是,如果我正在阅读ansible的文档,并且他们告诉你使用yum来安装一些软件包,然后点击来安装其他软件包......我遵循了这个指南,它让我陷入了这个混乱。我通过几次安装/重新安装所需的所有二进制文件解决了这个问题,直到它工作。它很混乱。 –