Bad HTTP response returned from the server. Code 500

2024/10/14 2:19:45

I have a problem to use pywinrm on linux, to get a PowerShell Session. I read several posts and questions on sites about that. But any that can solve my question.

The error is in the Kerberos autentication. This is my krb5.conf:

 0  [libdefaults] 1         default_realm = DOMAIN.COM.BR                                                                                                                          2         ticket_lifetime = 24000                                                                                                                                       3         clock-skew = 300                                                                                                                                              4         dns_lookup_kdc = true                                                                                                                                         5                                                                                                                                                                       6 # [realms]                                                                                                                                                            7 #         LABCORP.CAIXA.GOV.BR = {                                                                                                                                    8 #                 kdc = DOMAIN.COM.BR                                                                                                              9 #                 kdc = DOMAIN.COM.BR                                                                                                              
10 #                 admin_server = DOMAIN.COM.BR                                                                                         
11 #                 default_domain = DOMAIN.COM.BR                                                                                                        
12 #         }                                                                                                                                                           
13
14 [logging]                                                                                                                                                             
15                                                                                                                                                                       
16     default = FILE:/var/log/krb5libs.log                                                                                                                                  
17     kdc = FILE:/var/log/krb5kdc.log                                                                                                                                       
18     admin_server = FILE:/var/log/kadmind.log                                                                                                                              
19                                                                                                                                                                       
20 # [domain_realm]                                                                                                                                                      
21 #         .DOMAIN.COM.BR  = DOMAIN.COM.BR 
22 #         server.com = DOMAIN.COM.BR    

My /etc/resolv.conf is:

search DOMAIN.COM.BR 
nameserver IP 

And my python code is:

import winrms = winrm.Session('DOMAIN.COM.BR ','transport='kerberos',auth=('my_active_directory_user', 'my_active_directory_password'),server_cert_validation='ignore')r = s.run_cmd('ipconfig', ['/all'])

And the server return this error:

winrm.exceptions.WinRMTransportError: ('http', 'Bad HTTP response returned from server. Code 500')

The port of the server is open. I see with nmap:

5985/tcp  open  wsman 

I can ping and resolv the name of the server:

$ ping DOMAIN.COM.BR PING DOMAIN.COM.BR  (IP) 56(84) bytes of data.
64 bytes from IP: icmp_seq=2 ttl=127 time=0.410 ms
64 bytes from IP: icmp_seq=2 ttl=127 time=0.410 ms

I can use kinit without problem to get the ticket:

$ kinit [email protected] 

And, list the ticket:

$ klistTicket cache: FILE:/tmp/krb5cc_1000
Default principal: [email protected] Valid starting       Expires              Service principal
05-09-2017 10:23:52  05-09-2017 17:03:50  krbtgt/DOMAIN.COM.BR @DOMAIN.COM.BR 

What kind of problem is that?

Answer

Other solution is to add this line with allow_weak_crypto in your krb5.conf file:

[libdefaults]***allow_weak_crypto = true***
https://en.xdnf.cn/q/118010.html

Related Q&A

Iterate one list of synsets over another

I have two sets of wordnet synsets (contained in two separate list objects, s1 and s2), from which I want to find the maximum path similarity score for each synset in s1 onto s2 with the length of outp…

Flask werkzeug.routing.BuildError

I doing a flask app and when i try to put a link to redirect a user to his profile page by callingBuildError: Could not build url for endpoint profile. Did you forgetto specify values [business_name]?…

getting attribute of an element with its corresponding Id

suppose that i have this xml file :<article-set xmlns:ns0="http://casfwcewf.xsd" format-version="5"> <article><article id="11234"><source><hostn…

How to install selenium python on Mac

Ive downloaded the Selenium zip file for python and it contains the folder with the setup.py. It says on python.org that I have to type in terminal python setup.py install but it gives me this error th…

aws s3 - object has no attribute server_side_encryption

Can someone please explain the differences in these two calls. The first one gives the correct server_side_encryption and the second one gives an error. The other attributes give the same value-#!/usr/…

Removing nested for loop to find coincidence values

I am currently using a nested for loop to iterate through to arrays to find values that match a certain criterion. The problem is that this method is incredibly inefficient and time consuming. I was to…

Combine two pandas DataFrame into one new

I have two Pandas DataFrames whose data from different sources, but both DataFrames have the same column names. When combined only one column will keep the name.Like this:speed_df = pd.DataFrame.from_d…

Reasons of slowness in numpy.dot() function and how to mitigate them if custom classes are used?

I am profiling a numpy dot product call. numpy.dot(pseudo,pseudo)pseudo is a numpy array of custom objects. Defined as:pseudo = numpy.array([[PseudoBinary(1), PseudoBinary(0), PseudoBinary(1)],[PseudoB…

How to open cmd and run ipconfig in python

I would like to write a script that do something like that: open the cmd and run the commend "ipconfig" and than copy my ip and paste it to a text file. I wrote the beginning of the script …

Using OAuth to authenticate Office 365/Graph users with Django

We are creating an application for use in our organization, but we only want people in our organization to be able to use the app. We had the idea of using Microsofts OAuth endpoint in order to authent…