class_docstr: Representation of an SSH connection.
      
class_docstr_tok: ["Representation","of","an","SSH","connection","."]
docstr: Create a connection handler
  
  The actual opening of the connection is performed on-demand.
  
  Parameters
  ----------
  sshri: SSHRI
    SSH resource identifier (contains all connection-relevant info),
    or another resource identifier that can be converted into an SSHRI.
  identity_file : str or None
    Value to pass to ssh's -i option.
  use_remote_annex_bundle : bool, optional
    If enabled, look for a git-annex installation on the remote and
    prefer its Git binaries in the search path (i.e. prefer a bundled
    Git over a system package). See also the configuration setting
    datalad.ssh.try-use-annex-bundled-git
  force_ip : {False, 4, 6}
     Force the use of IPv4 or IPv6 addresses with -4 or -6.
  
  .. versionchanged:: 0.16
     The default for `use_remote_annex_bundle` changed from `True`
     to `None`. Instead of attempting to use a potentially available
     git-annex bundle on the remote host by default, this behavior
     is now conditional on the `datalad.ssh.try-use-annex-bundled-git`
     (off by default).
code: def __init__(
      self,
      sshri,
      identity_file=None,
      use_remote_annex_bundle=None,
      force_ip=False,
  ):
      """Create a connection handler
  
      The actual opening of the connection is performed on-demand.
  
      Parameters
      ----------
      sshri: SSHRI
        SSH resource identifier (contains all connection-relevant info),
        or another resource identifier that can be converted into an SSHRI.
      identity_file : str or None
        Value to pass to ssh's -i option.
      use_remote_annex_bundle : bool, optional
        If enabled, look for a git-annex installation on the remote and
        prefer its Git binaries in the search path (i.e. prefer a bundled
        Git over a system package). See also the configuration setting
        datalad.ssh.try-use-annex-bundled-git
      force_ip : {False, 4, 6}
         Force the use of IPv4 or IPv6 addresses with -4 or -6.
  
      .. versionchanged:: 0.16
         The default for `use_remote_annex_bundle` changed from `True`
         to `None`. Instead of attempting to use a potentially available
         git-annex bundle on the remote host by default, this behavior
         is now conditional on the `datalad.ssh.try-use-annex-bundled-git`
         (off by default).
      """
      self._runner = None
      self._ssh_executable = None
      self._ssh_version = None
  
      from datalad.support.network import SSHRI, is_ssh
  
      if not is_ssh(sshri):
          raise ValueError(
              "Non-SSH resource identifiers are not supported for SSH "
              "connections: {}".format(sshri)
          )
      self.sshri = SSHRI(
          **{
              k: v
              for k, v in sshri.fields.items()
              if k in ("username", "hostname", "port")
          }
      )
      # arguments only used for opening a connection
      self._ssh_open_args = []
      # arguments for annex ssh invocation
      self._ssh_args = []
      self._ssh_open_args.extend(
          ["-p", "{}".format(self.sshri.port)]
          if self.sshri.port
          else []
      )
      if force_ip:
          self._ssh_open_args.append("-{}".format(force_ip))
      if identity_file:
          self._ssh_open_args.extend(["-i", identity_file])
  
      self._use_remote_annex_bundle = use_remote_annex_bundle
      # essential properties of the remote system
      self._remote_props = {}
  
imports: import fasteners
  import os
  import logging
  from socket import gethostname
  from hashlib import md5
  from subprocess import Popen
  import tempfile
  import threading
  from datalad.utils import quote_cmdlinearg
  from datalad.support.exceptions import CapturedException, CommandError, ConnectionOpenFailedError
  from datalad.support.external_versions import external_versions
  from datalad.utils import auto_repr, Path, ensure_list, on_windows
  from datalad.cmd import NoCapture, StdOutErrCapture, WitlessRunner
  from ..None import cfg
label_desc: Use image node_id 1 to create a new BaseSSHConnection object from inherited base classes: object with example: obj = BaseSSHConnection(sshri, identity_file, use_remote_annex_bundle, force_ip)