Skip to content

Commit

Permalink
2.5.0 ssh_client remote client support Kerberos (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
wayyoungboy authored Sep 25, 2024
1 parent 25dc41a commit c36da7e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions common/ssh_client/remote_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


import os
import re
import sys
import time
import paramiko
Expand Down Expand Up @@ -93,14 +94,19 @@ def exec_cmd(self, cmd):
stdin, stdout, stderr = self._ssh_fd.exec_command(cmd)
err_text = stderr.read()
if len(err_text):
return err_text.decode('utf-8')
return stdout.read().decode('utf-8')
output_str = re.sub(r'klist: No credentials cache found \(filename: .+?\)', '', err_text.decode('utf-8'))
return output_str
# support Kerberos
output_str = re.sub(r'klist: No credentials cache found \(filename: .+?\)', '', stdout.read().decode('utf-8'))
return output_str
except UnicodeDecodeError as e:
self.stdio.warn("[remote] Execute Shell command UnicodeDecodeError, command=[{0}] Exception = [{1}]".format(cmd, e))
if stderr:
return str(stderr)
output_str = re.sub(r'klist: No credentials cache found \(filename: .+?\)', '', str(stderr))
return output_str
if stdout:
return str(stdout)
output_str = re.sub(r'klist: No credentials cache found \(filename: .+?\)', '', str(stdout))
return output_str
return ""
except SSHException as e:
raise OBDIAGShellCmdException("Execute Shell command on server {0} failed, " "command=[{1}], exception:{2}".format(self.host_ip, cmd, e))
Expand Down

0 comments on commit c36da7e

Please sign in to comment.