class_docstr: Keeps ssh connections to share. Serves singleton representation
  per connection.
  
  A custom identity file can be specified via `datalad.ssh.identityfile`.
  Callers are responsible for reloading `datalad.cfg` if they have changed
  this value since loading datalad.
class_docstr_tok: ["Keeps","ssh","connections","to","share",".","Serves","singleton","representation","per","connection",".","A","custom","identity","file","can","be","specified","via","`","datalad.ssh.identityfile","`",".","Callers","are","responsible","for","reloading","`","datalad.cfg","`","if","they","have","changed","this","value","since","loading","datalad","."]
docstr: Closes all connections, known to this instance.
  
  Parameters
  ----------
  allow_fail: bool, optional
    If True, swallow exceptions which might be thrown during
    connection.close, and just log them at DEBUG level
  ctrl_path: str, Path, or list of str or Path, optional
    If specified, only the path(s) provided would be considered
code: def close(self, allow_fail=True, ctrl_path=None):
      """Closes all connections, known to this instance.
  
      Parameters
      ----------
      allow_fail: bool, optional
        If True, swallow exceptions which might be thrown during
        connection.close, and just log them at DEBUG level
      ctrl_path: str, Path, or list of str or Path, optional
        If specified, only the path(s) provided would be considered
      """
      if self._connections:
          ctrl_paths = [Path(p) for p in ensure_list(ctrl_path)]
          to_close = [
              c
              for c in self._connections
              # don't close if connection wasn't opened by SSHManager
              if self._connections[c].ctrl_path
              not in self._prev_connections
              and self._connections[c].ctrl_path.exists()
              and (
                  not ctrl_paths
                  or self._connections[c].ctrl_path in ctrl_paths
              )
          ]
          if to_close:
              lgr.debug("Closing %d SSH connections...", len(to_close))
          for cnct in to_close:
              f = self._connections[cnct].close
              if allow_fail:
                  f()
              else:
                  try:
                      f()
                  except Exception as exc:
                      ce = CapturedException(exc)
                      lgr.debug(
                          "Failed to close a connection: " "%s",
                          ce.message,
                      )
          self._connections = dict()
  
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 5 for calling the MultiplexSSHManager obj's underlying member method code with example usage: obj.close(allow_fail, ctrl_path) without return types