{ "info": { "author": "Alexey Diyan", "author_email": "alexey.diyan@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Clustering", "Topic :: System :: Distributed Computing", "Topic :: System :: Systems Administration" ], "description": "# pywinrm \npywinrm is a Python client for the Windows Remote Management (WinRM) service.\nIt allows you to invoke commands on target Windows machines from any machine\nthat can run Python.\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/diyan/pywinrm/blob/master/LICENSE)\n[![Travis Build](https://travis-ci.org/diyan/pywinrm.svg)](https://travis-ci.org/diyan/pywinrm)\n[![AppVeyor Build](https://ci.appveyor.com/api/projects/status/github/diyan/pywinrm?svg=true)](https://ci.appveyor.com/project/diyan/pywinrm) [![Coverage](https://coveralls.io/repos/diyan/pywinrm/badge.svg)](https://coveralls.io/r/diyan/pywinrm)\n[![PyPI](https://img.shields.io/pypi/dm/pywinrm.svg)](https://pypi.python.org/pypi/pywinrm)\n\nWinRM allows you to perform various management tasks remotely. These include, \nbut are not limited to: running batch scripts, powershell scripts, and fetching \nWMI variables.\n\nUsed by [Ansible](https://www.ansible.com/) for Windows support.\n\nFor more information on WinRM, please visit\n[Microsoft's WinRM site](http://msdn.microsoft.com/en-us/library/aa384426.aspx).\n\n## Requirements\n* Linux, Mac OS X or Windows\n* CPython 2.6-2.7, 3.3-3.5 or PyPy2\n* [requests-kerberos](http://pypi.python.org/pypi/requests-kerberos) and [requests-credssp](https://github.com/jborean93/requests-credssp) is optional\n\n## Installation\n### To install pywinrm with support for basic, certificate, and NTLM auth, simply\n```bash\n$ pip install pywinrm\n```\n\n### To use Kerberos authentication you need these optional dependencies\n\n```bash\n# for Debian/Ubuntu/etc:\n$ sudo apt-get install gcc python-dev libkrb5-dev\n$ pip install pywinrm[kerberos]\n\n# for RHEL/CentOS/etc:\n$ sudo yum install gcc python-devel krb5-devel krb5-workstation python-devel\n$ pip install pywinrm[kerberos]\n```\n\n### To use CredSSP authentication you need these optional dependencies\n\n```bash\n# for Debian/Ubuntu/etc:\n$ sudo apt-get install gcc python-dev libssl-dev\n$ pip install pywinrm[credssp]\n\n# for RHEL/CentOS/etc:\n$ sudo yum install gcc python-devel openssl-devel\n$ pip install pywinrm[credssp]\n```\n\n## Example Usage\n### Run a process on a remote host\n```python\nimport winrm\n\ns = winrm.Session('windows-host.example.com', auth=('john.smith', 'secret'))\nr = s.run_cmd('ipconfig', ['/all'])\n>>> r.status_code\n0\n>>> r.std_out\nWindows IP Configuration\n\n Host Name . . . . . . . . . . . . : WINDOWS-HOST\n Primary Dns Suffix . . . . . . . :\n Node Type . . . . . . . . . . . . : Hybrid\n IP Routing Enabled. . . . . . . . : No\n WINS Proxy Enabled. . . . . . . . : No\n...\n>>> r.std_err\n\n```\n\nNOTE: pywinrm will try and guess the correct endpoint url from the following formats:\n\n - windows-host -> http://windows-host:5985/wsman\n - windows-host:1111 -> http://windows-host:1111/wsman\n - http://windows-host -> http://windows-host:5985/wsman\n - http://windows-host:1111 -> http://windows-host:1111/wsman\n - http://windows-host:1111/wsman -> http://windows-host:1111/wsman\n\n\n### Run Powershell script on remote host\n\n```python\nimport winrm\n\nps_script = \"\"\"$strComputer = $Host\nClear\n$RAM = WmiObject Win32_ComputerSystem\n$MB = 1048576\n\n\"Installed Memory: \" + [int]($RAM.TotalPhysicalMemory /$MB) + \" MB\" \"\"\"\n\ns = winrm.Session('windows-host.example.com', auth=('john.smith', 'secret'))\nr = s.run_ps(ps_script)\n>>> r.status_code\n0\n>>> r.std_out\nInstalled Memory: 3840 MB\n\n>>> r.std_err\n\n```\n\nPowershell scripts will be base64 UTF16 little-endian encoded prior to sending to the Windows host. Error messages are converted from the Powershell CLIXML format to a human readable format as a convenience.\n\n### Run process with low-level API with domain user, disabling HTTPS cert validation\n\n```python\nfrom winrm.protocol import Protocol\n\np = Protocol(\n endpoint='https://windows-host:5986/wsman',\n transport='ntlm',\n username=r'somedomain\\someuser',\n password='secret',\n server_cert_validation='ignore')\nshell_id = p.open_shell()\ncommand_id = p.run_command(shell_id, 'ipconfig', ['/all'])\nstd_out, std_err, status_code = p.get_command_output(shell_id, command_id)\np.cleanup_command(shell_id, command_id)\np.close_shell(shell_id)\n```\n\n### Valid transport options\n\npywinrm supports various transport methods in order to authenticate with the WinRM server. The options that are supported in the `transport` parameter are;\n* `basic`: Basic auth only works for local Windows accounts not domain accounts. Credentials are base64 encoded when sending to the server.\n* `plaintext`: Same as basic auth.\n* `certificate`: Authentication is done through a certificate that is mapped to a local Windows account on the server.\n* `ssl`: When used in conjunction with `cert_pem` and `cert_key_pem` it will use a certificate as above. If not will revert to basic auth over HTTPS.\n* `kerberos`: Will use Kerberos authentication for domain accounts which only works when the client is in the same domain as the server and the required dependencies are installed. Currently a Kerberos ticket needs to be initialized outside of pywinrm using the `kinit` command.\n* `ntlm`: Will use NTLM authentication for both domain and local accounts.\n* `credssp`: Will use CredSSP authentication for both domain and local accounts. Allows double hop authentication. This only works over a HTTPS endpoint and not HTTP.\n\n### Encryption\n\nBy default, WinRM will not accept unencrypted communication with a client. There are two ways\nto enable encrypted communication with pywinrm:\n\n1. Use an HTTPS endpoint instead of HTTP (Recommended)\n2. Use NTLM, Kerberos, or CredSSP as the transport auth\n\nUsing an HTTPS endpoint is recommended, as it will encrypt all the data sent\nto the server (including all headers), works securely with all\nauth types, and can properly verify remote host identity (when used with certificates signed by a \nverifiable certificate authority). You can use [this script](https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1)\nto easily set up a HTTPS endpoint on WinRM with a self-signed certificate, but\nthe use of a verifiable certificate authority is recommended in production environments.\n\nThe second option is to use NTLM, Kerberos, or CredSSP, and set the `message_encryption`\narg to protocol to `auto` (the default value) or `always`. This will use the authentication GSS-API\nWrap and Unwrap methods to encrypt the message contents sent to\nthe server. This form of encryption is independent of the transport layer, and the strength of the encryption\nused varies with the underlying authentication type selected (NTLM generally being the weakest and CredSSP the\nstrongest). \n\nTo configure message encryption you can use the `message_encryption` argument\nwhen initialising protocol. This option has 3 values that can be set as shown\nbelow.\n\n* `auto`: Default, Will only use message encryption if it is available for the auth method and HTTPS isn't used.\n* `never`: Will never use message encryption even when not over HTTPS.\n* `always`: Will always use message encryption even when running over HTTPS (fails if encryption support is unavailable on the selected auth method).\n\nIf you set the value to `always` and the transport opt doesn't support message\nencryption (e.g., `basic` auth or an old version of `pykerberos` without message \nencryption support is installed), pywinrm will throw an exception.\n\nIf you do not use an HTTPS endpoint or message encryption, a default-configured WinRM\nserver will automatically reject requests from pywinrm. Server settings can be modified\nallow unencrypted messages and credentials, but this is highly\ninsecure and should only be used for diagnostic purposes. To allow unencrypted communications,\nrun the following on the WinRM server (cmd and powershell versions provided):\n\n```\n# from cmd\nwinrm set winrm/config/service @{AllowUnencrypted=\"true\"}\n\n# or from powershell\nSet-Item -Path \"WSMan:\\localhost\\Service\\AllowUnencrypted\" -Value $true\n```\n\nAgain, this should *not* be used in production environments, as your credentials and WinRM \nmessages can be trivially recovered.\n\n\n### Enabling WinRM on remote host\nEnable WinRM over HTTP and HTTPS with self-signed certificate (includes firewall rules):\n\n```\n# from powershell:\nInvoke-Expression ((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))\n```\n\nEnable WinRM over HTTP for test usage (includes firewall rules):\n```\nwinrm quickconfig\n```\n\nEnable WinRM basic authentication. For domain users, it is necessary to use NTLM, Kerberos, or CredSSP authentication (Kerberos and NTLM authentication are enabled by default, CredSSP is not).\n```\n# from cmd:\nwinrm set winrm/config/service/auth @{Basic=\"true\"}\n```\n\nEnable WinRM CredSSP authentication. This allows double hop support so you can authenticate with a network service when running command son the remote host. This command is run in Powershell.\n```powershell\nEnable-WSManCredSSP -Role Server -Force\nSet-Item -Path \"WSMan:\\localhost\\Service\\Auth\\CredSSP\" -Value $true\n```\n\n### Contributors (alphabetically)\n\n- Alessandro Pilotti\n- Alexey Diyan\n- Chris Church\n- David Cournapeau\n- Gema Gomez\n- Jijo Varghese\n- Jordan Borean\n- Juan J. Martinez\n- Lukas Bednar\n- Manuel Sabban\n- Matt Clark\n- Matt Davis\n- Maxim Kovgan\n- Nir Cohen\n- Patrick Dunnigan\n- Reina Abolofia\n\nWant to help - send a pull request. I will accept good pull requests for sure.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/diyan/pywinrm/", "keywords": "winrm,ws-man,devops,ws-management", "license": "MIT license", "maintainer": "Thomas Grainger", "maintainer_email": "pywinrm@graingert.co.uk", "name": "pywinrm2", "package_url": "https://pypi.org/project/pywinrm2/", "platform": "", "project_url": "https://pypi.org/project/pywinrm2/", "project_urls": { "Homepage": "http://github.com/diyan/pywinrm/" }, "release_url": "https://pypi.org/project/pywinrm2/0.0.0/", "requires_dist": [ "xmltodict", "requests (>=2.9.1)", "requests-ntlm (>=0.3.0)", "six", "requests-credssp (>=0.0.1) ; extra == 'credssp'", "requests-kerberos (>=0.10.0) ; extra == 'kerberos'" ], "requires_python": "", "summary": "Python library for Windows Remote Management", "version": "0.0.0" }, "last_serial": 4838963, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "d8071c8ab9a158c03db39551453b465d", "sha256": "1c0e36480d01db07709c77b542e72da1db2e896bb36b97c47e6fc2802621506e" }, "downloads": -1, "filename": "pywinrm2-0.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d8071c8ab9a158c03db39551453b465d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 30710, "upload_time": "2019-01-29T15:15:26", "url": "https://files.pythonhosted.org/packages/a2/12/76450cb5be94b08f3bfec1219c48435c088b5e005f4697b54fd10692c279/pywinrm2-0.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0f2053e306b72716560408e073ad4a4b", "sha256": "1bfe53cb40685c32411282cf9d5d71f2f7a41adaef48f23db46c549d95ee9748" }, "downloads": -1, "filename": "pywinrm2-0.0.0.tar.gz", "has_sig": false, "md5_digest": "0f2053e306b72716560408e073ad4a4b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26750, "upload_time": "2019-01-29T15:15:29", "url": "https://files.pythonhosted.org/packages/16/29/c83e213c685e5caae18965936502a86b8900b212b39b1318af35591b2d44/pywinrm2-0.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d8071c8ab9a158c03db39551453b465d", "sha256": "1c0e36480d01db07709c77b542e72da1db2e896bb36b97c47e6fc2802621506e" }, "downloads": -1, "filename": "pywinrm2-0.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d8071c8ab9a158c03db39551453b465d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 30710, "upload_time": "2019-01-29T15:15:26", "url": "https://files.pythonhosted.org/packages/a2/12/76450cb5be94b08f3bfec1219c48435c088b5e005f4697b54fd10692c279/pywinrm2-0.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0f2053e306b72716560408e073ad4a4b", "sha256": "1bfe53cb40685c32411282cf9d5d71f2f7a41adaef48f23db46c549d95ee9748" }, "downloads": -1, "filename": "pywinrm2-0.0.0.tar.gz", "has_sig": false, "md5_digest": "0f2053e306b72716560408e073ad4a4b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26750, "upload_time": "2019-01-29T15:15:29", "url": "https://files.pythonhosted.org/packages/16/29/c83e213c685e5caae18965936502a86b8900b212b39b1318af35591b2d44/pywinrm2-0.0.0.tar.gz" } ] }