コード例 #1
0
class ForwardOnlyTransport(transport.SSHClientTransport):
    '''
    transport used to stablish the connection over ssh, it will allow only
    remote port forwarding, no hostkey verification is done.
    '''
    def __init__(self, options, *args, **kwargs):
        self.options = options
        self.conn = None
        self.user= options['user']
        
    def verifyHostKey(self, hostKey, fingerprint):
        """just say it's fine to use this key"""
        print 'host key fingerprint: %s' % fingerprint
        return defer.succeed(True) 

    def connectionSecure(self):
        '''
        called when the ssh link is created, login now, then handle control
        to ForwardOnlySSHConnection
        '''
        self.conn=ForwardOnlySSHConnection()
        self.conn.register_onConnect(self.OnConnect)
        self.requestService(
            ForwardOnlyUserAuth(self.user,self.conn)
            )

    def OnConnect(self):
        """
        connected and logged in, it's time to forward the ports
        """
        if self.options.remoteForwards:
            for remotePort, hostport in self.options.remoteForwards:
                print 'asking for remote forwarding for %s:%s' % (remotePort, 
                                                                  hostport)
                self.conn.requestRemoteForwarding(remotePort, hostport)
コード例 #2
0
class ForwardOnlyTransport(transport.SSHClientTransport):
    '''
    transport used to stablish the connection over ssh, it will allow only
    remote port forwarding, no hostkey verification is done.
    '''
    def __init__(self, options, *args, **kwargs):
        self.options = options
        self.conn = None
        self.user = options['user']

    def verifyHostKey(self, hostKey, fingerprint):
        """just say it's fine to use this key"""
        print 'host key fingerprint: %s' % fingerprint
        return defer.succeed(True)

    def connectionSecure(self):
        '''
        called when the ssh link is created, login now, then handle control
        to ForwardOnlySSHConnection
        '''
        self.conn = ForwardOnlySSHConnection()
        self.conn.register_onConnect(self.OnConnect)
        self.requestService(ForwardOnlyUserAuth(self.user, self.conn))

    def OnConnect(self):
        """
        connected and logged in, it's time to forward the ports
        """
        if self.options.remoteForwards:
            for remotePort, hostport in self.options.remoteForwards:
                print 'asking for remote forwarding for %s:%s' % (remotePort,
                                                                  hostport)
                self.conn.requestRemoteForwarding(remotePort, hostport)
コード例 #3
0
 def connectionSecure(self):
     '''
     called when the ssh link is created, login now, then handle control
     to ForwardOnlySSHConnection
     '''
     self.conn = ForwardOnlySSHConnection()
     self.conn.register_onConnect(self.OnConnect)
     self.requestService(ForwardOnlyUserAuth(self.user, self.conn))
コード例 #4
0
 def connectionSecure(self):
     '''
     called when the ssh link is created, login now, then handle control
     to ForwardOnlySSHConnection
     '''
     self.conn=ForwardOnlySSHConnection()
     self.conn.register_onConnect(self.OnConnect)
     self.requestService(
         ForwardOnlyUserAuth(self.user,self.conn)
         )