【发布时间】:2015-09-01 05:17:31
【问题描述】:
我想使用 pywinrm 库在 Python 中编写一个脚本,以便能够通过 WinRM 连接到远程机器。
import winrm
s = winrm.Session('MACHINEHOST', auth=('username@domain', 'password'))
r = s.run_cmd('ipconfig', ['/all'])
print r.status_code
print r.std_out
当我使用本地用户时,脚本运行良好。当我使用域用户时,我收到以下异常:
winrm.exceptions.UnauthorizedError: 401 Unauthorized.
关于远程机器上的 WinRM 配置:
/Client/Auth/Basic = True
/Client/TrustedHosts = *
/Service/Auth/Basic = True
/Service/AllowUnencrypted = True
您能建议如何解决这个问题吗?
谢谢。
【问题讨论】:
-
建议对域中的远程主机使用 Kerberos。