def start_interactive_shell(self, command=None, initial_input=None, sandbox=False):
        """
        Start /bin/bash and redirect all SSH I/O from stdin and to stdout.
        """
        # Start a new shell using the same dimentions as the current terminal
        height, width = self.pty.get_size()
        chan = self._backend.get_ssh(self).invoke_shell(term=self.pty.get_term_var(), height=height, width=width)

        # Keep size of local pty and remote pty in sync
        def set_size():
            height, width = self.pty.get_size()
            chan.resize_pty(width=width, height=height)
        self.pty.set_ssh_channel_size = set_size

        # Start logger
        with self.logger.log_run(self, command=command, shell=True, sandboxing=sandbox) as log_entry:
            # When a command has been passed, use 'exec' to replace the current
            # shell process by this command
            if command:
                chan.send('exec %s\n' % command)

            # PTY receive/send loop
            self._posix_shell(chan, initial_input=initial_input)

            # Retrieve status code
            status_code = chan.recv_exit_status()
            log_entry.set_status_code(status_code)

            self.pty.set_ssh_channel_size = None

            # Return status code
            return status_code
dataset/ETHPy150Open jonathanslenders/python-deployer/deployer/host/ssh.py/SSHHost.start_interactive_shell/original