code: def start_ssh_server(port, username, password, namespace):
      
      # This is a lot of boilerplate, see http://tm.tl/6429 for a ticket to
      # provide a utility function that simplifies this.
      from twisted.internet import reactor
      from twisted.conch.insults import insults
      from twisted.conch import manhole, manhole_ssh
      from twisted.cred.checkers import (
          InMemoryUsernamePasswordDatabaseDontUse as MemoryDB)
      from twisted.cred.portal import Portal
  
      sshRealm = manhole_ssh.TerminalRealm()
      def chainedProtocolFactory():
          return insults.ServerProtocol(manhole.Manhole, namespace)
      sshRealm.chainedProtocolFactory = chainedProtocolFactory
  
      sshPortal = Portal(sshRealm, [MemoryDB(**{username: password})])
      reactor.listenTCP(port, manhole_ssh.ConchFactory(sshPortal),
                        interface="127.0.0.1")
docs: Start an SSH server on the given port, exposing a Python prompt with the
      given namespace.