通过Python连接到Windows共享时出现无法解释的超时-pysmb

时间:2018-11-23 07:48:24

标签: python samba pysmb

我正在使用下面的python代码连接到Windows远程共享。

   self.connection = SMBConnection(
        username=user,
        password=password,
        my_name=client_machine_name,
        remote_name=server_name,
        domain=domain,
        use_ntlm_v2=True,
        sign_options=2,
        is_direct_tcp=True,
    )

    self.logger.info(
        "Attempting to authenticate %s\%s on %s", domain, user, server_name
    )

    self.connection.connect(server_name, 445)

该代码由每日脚本使用,该脚本直到今天开始超时才可以正常工作。可能是什么原因?

nmap告诉我端口已打开

Host is up (1.0s latency).      
Not shown: 988 closed ports     
PORT      STATE SERVICE         
111/tcp   open  rpcbind         
135/tcp   open  msrpc           
139/tcp   open  netbios-ssn     
161/tcp   open  snmp            
445/tcp   open  microsoft-ds    
1234/tcp  open  hotline         
2049/tcp  open  nfs             
5033/tcp  open  unknown         
7777/tcp  open  cbt             
8888/tcp  open  sun-answerbook  
10000/tcp open  snet-sensor-mgmt
12345/tcp open  netbus

smbclient也超时

bash$ smbclient -L xxx.xxx.xxx.xxx -U domain\\user -d 5                          
INFO: Current debug levels:                                                                                
  all: 5                                                                                                   
  tdb: 5                                                                                                   
  printdrivers: 5                                                                                          
  lanman: 5                                                                                                
  smb: 5                                                                                                   
  rpc_parse: 5                                                                                             
  rpc_srv: 5                                                                                               
  rpc_cli: 5                                                                                               
  passdb: 5                                                                                                
  sam: 5                                                                                                   
  auth: 5                                                                                                  
  winbind: 5                                                                                               
  vfs: 5                                                                                                   
  idmap: 5                                                                                                 
  quota: 5                                                                                                 
  acls: 5                                                                                                  
  locking: 5                                                                                               
  msdfs: 5                                                                                                 
  dmapi: 5                                                                                                 
  registry: 5                                                                                              
  scavenger: 5                                                                                             
  dns: 5                                                                                                   
  ldb: 5                                                                                                   
  tevent: 5                                                                                                
  auth_audit: 5                                                                                            
  auth_json_audit: 5                                                                                       
  kerberos: 5                                                                                              
  drs_repl: 5                                                                                              
lp_load_ex: refreshing parameters                                                                          
Initialising global parameters                                                                             
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)                                  
INFO: Current debug levels:                                                                                
  all: 5                                                                                                   
  tdb: 5                                                                                                   
  printdrivers: 5                                                                                          
  lanman: 5                                                                                                
  smb: 5                                                                                                   
  rpc_parse: 5                                                                                             
  rpc_srv: 5                                                                                               
  rpc_cli: 5                                                                                               
  passdb: 5                                                                                                
  sam: 5                                                                                                   
  auth: 5                                                                                                  
  winbind: 5                                                                                               
  vfs: 5                                                                                                   
  idmap: 5                                                                                                 
  quota: 5                                                                                                 
  acls: 5                                                                                                  
  locking: 5                                                                                               
  msdfs: 5                                                                                                 
  dmapi: 5                                                                                                 
  registry: 5                                                                                              
  scavenger: 5                                                                                             
  dns: 5                                                                                                   
  ldb: 5                                                                                                   
  tevent: 5                                                                                                
  auth_audit: 5                                                                                            
  auth_json_audit: 5                                                                                       
  kerberos: 5                                                                                              
  drs_repl: 5                                                                                              
Processing section "[global]"                                                                              
doing parameter workgroup = SAMBA                                                                          
doing parameter security = user                                                                            
doing parameter passdb backend = tdbsam                                                                    
doing parameter printing = cups                                                                            
doing parameter printcap name = cups                                                                       
doing parameter load printers = yes                                                                        
doing parameter cups options = raw                                                                         
pm_process() returned Yes                                                                                  
added interface docker0 ip=xxx.xxx.xxx.xxx bcast=xxx.xxx.xxx.xxx netmask=xxx.xxx.xxx.xxx                             
added interface br-f26a4e627922 ip=xxx.xxx.xxx.xxx bcast=xxx.xxx.xxx.xxx netmask=xxx.xxx.xxx.xxx                    
added interface br-fc09ee069011 ip=xxx.xxx.xxx.xxx bcast=xxx.xxx.xxx.xxx netmask=xxx.xxx.xxx.xxx                    
added interface enp0s3 ip=xxx.xxx.xxx.xxx bcast=xxx.xxx.xxx.xxx netmask=xxx.xxx.xxx.xxx                                 
Netbios name list:-                                                                                        
my_netbios_names[0]="LOCALHOST"                                                                            
Client started (version 4.7.1).                                                                            
Connecting to xxx.xxx.xxx.xxx at port 445                                                                   
Connecting to xxx.xxx.xxx.xxx at port 139                                                                   
Socket options:                                                                                            
        SO_KEEPALIVE = 0                                                                                   
        SO_REUSEADDR = 0                                                                                   
        SO_BROADCAST = 0                                                                                   
        TCP_NODELAY = 1                                                                                    
        TCP_KEEPCNT = 9                                                                                    
        TCP_KEEPIDLE = 7200                                                                                
        TCP_KEEPINTVL = 75                                                                                 
        IPTOS_LOWDELAY = 0                                                                                 
        IPTOS_THROUGHPUT = 0                                                                               
        SO_REUSEPORT = 0                                                                                   
        SO_SNDBUF = 87040                                                                                  
        SO_RCVBUF = 369280                                                                                 
        SO_SNDLOWAT = 1                                                                                    
        SO_RCVLOWAT = 1                                                                                    
        SO_SNDTIMEO = 0                                                                                    
        SO_RCVTIMEO = 0                                                                                    
        TCP_QUICKACK = 1                                                                                   
        TCP_DEFER_ACCEPT = 0                                                                               
 session request ok                                                                                        
protocol negotiation failed: NT_STATUS_IO_TIMEOUT                                                          

0 个答案:

没有答案