def connection(self):
    if not self.is_connected():
        self._ssh = paramiko.SSHClient()
self._ssh.connect(self.server, self.port, username=self.username, password=
    self.password)
return self._ssh

def is_connected(self):
    transport = self._ssh.get_transport() if self._ssh else None
return transport and transport.is_active()

def do_something(self):
    self.connection().exec_command('ls')
Как узнать, отключен ли канал paramiko SSH?