2017-09-05 14 views
0

J'ai un problème pour utiliser pywinrm sous linux, pour obtenir une session PowerShell. J'ai lu plusieurs messages et questions sur les sites à ce sujet. Mais tout ce qui peut résoudre ma question.Mauvaise réponse HTTP renvoyée par le serveur. Code 500

L'erreur est dans l'autentication Kerberos. Ceci est mon krb5.conf:

0 [libdefaults] 
1   default_realm = LABCORP.CAIXA.GOV.BR                               
2   ticket_lifetime = 24000                                  
3   clock-skew = 300                                    
4   dns_lookup_kdc = true                                   
5                                          
6 # [realms]                                        
7 #   LABCORP.CAIXA.GOV.BR = {                                  
8 #     kdc = DFLABSAIL003.LABCORP.CAIXA.GOV.BR                            
9 #     kdc = dflabsail003.labcorp.caixa.gov.br                            
10 #     admin_server = DFLABSAIL003.LABCORP.CAIXA.GOV.BR:464                       
11 #     default_domain = LABCORP.CAIXA.GOV.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 #   .labcorp.caixa.gov.br = LABCORP.CAIXA.GOV.BR 
22 #   server.com = LABCORP.CAIXA.GOV.BR 

Mon /etc/resolv.conf est:

search labcorp.caixa.gov.br 
nameserver 10.196.20.143 

Et mon code python est:

import winrm 

s = winrm.Session(
    'dflabsail003.labcorp.caixa.gov.br', 
    'transport='kerberos', 
    auth=('my_active_directory_user', 'my_active_directory_password'), 
    server_cert_validation='ignore') 

r = s.run_cmd('ipconfig', ['/all']) 

Et le retour du serveur cette erreur:

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

Le port du serveur est ouvert. Je vois avec nmap:

5985/tcp open wsman 

Je peux cingler et RESOLV le nom du serveur:

$ ping dflabsail003.labcorp.caixa.gov.br 

PING dflabsail003.labcorp.caixa.gov.br (10.196.20.144) 56(84) bytes of data. 
64 bytes from 10.196.20.144: icmp_seq=2 ttl=127 time=0.410 ms 
64 bytes from 10.196.20.144: icmp_seq=2 ttl=127 time=0.410 ms 

Je peux utiliser kinit sans problème pour obtenir le billet:

$ kinit [email protected] 

Et, Lister le ticket:

$ klist 

Ticket 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/[email protected] 

Quoi genre de problème est-ce?

Répondre

1

Autre solution est d'ajouter cette ligne avec allow_weak_crypto dans votre fichier krb5.conf:

[libdefaults] 
    *** 
    allow_weak_crypto = true 
    ***