jborean93 / pypsrp

PowerShell Remoting Protocol for Python
MIT License
324 stars 49 forks source link

Failed to connect using WSMan with ssl=True #143

Closed anshulmgupta closed 2 years ago

anshulmgupta commented 2 years ago

Hi @jborean93 I am able to connect to the Windows server with ssl=False, encryption="never" and using basic auth, however when I changed ssl=True I am unable to connect using WSMan.


wsman = WSMan(hostname,
                               ssl=True,
                               auth="basic",
                               encryption="auto",
                               username,
                               password)

With below error
HTTPSConnectionPool(host='hostname', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fe373ac9da0>: Failed to establish a new connection: [Errno 111] Connection refused',))

The above works with ssl=False and encryption="never" Any guidance on how could I solve this issue? Thanks!

jborean93 commented 2 years ago

Have you enabled a HTTPS listener for WinRM on the server, Have you allowed traffic in for port 5986? Best bet for testing out TLS connection is to run the following command:

echo "Y" | openssl s_client -connect hostname:5986

If this is able to connect you should be able to use this library to connect to the same endpoint. If this fails then you need to figure out what isn't enabled on your Windows host to allow HTTPS traffic.

anshulmgupta commented 2 years ago

Thanks @jborean93