class_docstr: An AutoDist Cluster Based on SSH.
docstr: Execute a bash script remotely.
  
  Args:
      args (list): bash commands
      hostname (str): host name or address
  
  Returns:
      Process: process handle
docstr_tok: ["Execute","a","bash","script","remotely",".","Args",":","args","(","list",")",":","bash","commands","hostname","(","str",")",":","host","name","or","address","Returns",":","Process",":","process","handle"]
code: def remote_exec(self, args, hostname):
      """
      Execute a bash script remotely.
  
      Args:
          args (list): bash commands
          hostname (str): host name or address
  
      Returns:
          Process: process handle
      """
      cmd_list = []
      ssh_config = self._ssh_conf[hostname]
      if ssh_config.python_venv:
          cmd_list.append("%s;" % ssh_config.python_venv)
      if ssh_config.env:
          cmd_list.extend(
              ["%s=%s" % (k, v) for k, v in ssh_config.env.items()]
          )
      full_cmd = " ".join(cmd_list + args)
  
      remote_cmd = "ssh -i {} -o StrictHostKeyChecking=no -tt -p {} {}@{} 'bash -c \"{}\"' </dev/null".format(
          ssh_config.key_file,
          ssh_config.port,
          ssh_config.username,
          hostname,
          full_cmd,
      )
  
      logging.debug("$ %s" % remote_cmd)
  
      if ENV.AUTODIST_DEBUG_REMOTE.val:
          return None
  
      # pylint: disable=subprocess-popen-preexec-fn
      proc = subprocess.Popen(
          remote_cmd, shell=True, preexec_fn=os.setsid
      )
      return proc
  
imports: import atexit
  import contextlib
  import json
  import os
  import signal
  import subprocess
  import sys
  import warnings
  from abc import ABCMeta, abstractmethod
  import paramiko
  from autodist.const import DEFAULT_PORT_RANGE, DEFAULT_WORKING_DIR, ENV
  from autodist.resource_spec import ResourceSpec
  from autodist.utils import logging
label_desc: Use image node_id 4 for calling the SSHCluster obj's underlying member method code with example usage: obj.remote_exec(args, hostname) and returns: proc, None