from twisted.conch.ssh import forwarding
LOCALPORT = 8888
REMOTEHOST = '127.0.0.1'
REMOTEPORT = 9999


class Connection(connection.SSHConnection):

    def serviceStarted(self):
        Channel = forwarding.SSHListenClientForwardingChannel
Factory = forwarding.SSHListenForwardingFactory
factory = Factory(self, (REMOTEHOST, REMOTEPORT), Channel)
s = reactor.listenTCP(LOCALPORT, factory)
How can I do SSH port forwarding from within Python Twisted?