import winrm
ip = "1.1.1.1"
user = r"xha\sss"
password = "se123"
s = winrm.Session(ip, auth=(user, password))
r = s.run_command("ifconfig")
print(r.std_out)
报错如下
File "./windows.py", line 18, in
shell_id = p.open_shell()
File "/usr/lib/python2.6/site-packages/winrm/protocol.py", line 118,
in open_shell
rs = self.send_message(xmltodict.unparse(rq))
File "/usr/lib/python2.6/site-packages/winrm/protocol.py", line 190,
in send_message
return self.transport.send_message(message)
File "/usr/lib/python2.6/site-packages/winrm/transport.py", line 99,
in send_message
raise UnauthorizedError(transport='plaintext', message=ex.msg)
winrm.exceptions.UnauthorizedError: 401 Unauthorized. basic auth failed