def get_tunnel(self, remote_port, remote_host="localhost", local_port=None):
        """
        Creates a tunnel between two hosts. Like ssh -L <LOCAL_PORT>:host:<REMOTE_PORT>.

        :param remote_port: The remote port to create a tunnel to
        :type remote_port: int
        :param remote_host: The remote host to create a tunnel to (default localhost)
        :type remote_host: str
        :param local_port:  The local port to attach the tunnel to
        :type local_port: int

        :return: sshtunnel.SSHTunnelForwarder object
        """

        if local_port:
            local_bind_address = ('localhost', local_port)
        else:
            local_bind_address = ('localhost',)

        if self.password and self.password.strip():
            client = SSHTunnelForwarder(self.remote_host,
                                        ssh_port=self.port,
                                        ssh_username=self.username,
                                        ssh_password=self.password,
                                        ssh_pkey=self.key_file,
                                        ssh_proxy=self.host_proxy,
                                        local_bind_address=local_bind_address,
                                        remote_bind_address=(remote_host, remote_port),
                                        logger=self.log)
        else:
            client = SSHTunnelForwarder(self.remote_host,
                                        ssh_port=self.port,
                                        ssh_username=self.username,
                                        ssh_pkey=self.key_file,
                                        ssh_proxy=self.host_proxy,
                                        local_bind_address=local_bind_address,
                                        remote_bind_address=(remote_host, remote_port),
                                        host_pkey_directories=[],
                                        logger=self.log)

        return client
def get_tunnel(self, remote_port, remote_host="localhost", local_port=None):
        """
        Creates a tunnel between two hosts. Like ssh -L <LOCAL_PORT>:host:<REMOTE_PORT>.

        :param remote_port: The remote port to create a tunnel to
        :type remote_port: int
        :param remote_host: The remote host to create a tunnel to (default localhost)
        :type remote_host: str
        :param local_port:  The local port to attach the tunnel to
        :type local_port: int

        :return: sshtunnel.SSHTunnelForwarder object
        """

        if local_port:
            local_bind_address = ('localhost', local_port)
        else:
            local_bind_address = ('localhost',)

        if self.password and self.password.strip():
            client = SSHTunnelForwarder(self.remote_host,
                                        ssh_port=self.port,
                                        ssh_username=self.username,
                                        ssh_password=self.password,
                                        ssh_pkey=self.key_file,
                                        ssh_proxy=self.host_proxy,
                                        local_bind_address=local_bind_address,
                                        remote_bind_address=(remote_host, remote_port),
                                        logger=self.log)
        else:
            client = SSHTunnelForwarder(self.remote_host,
                                        ssh_port=self.port,
                                        ssh_username=self.username,
                                        ssh_pkey=self.key_file,
                                        ssh_proxy=self.host_proxy,
                                        local_bind_address=local_bind_address,
                                        remote_bind_address=(remote_host, remote_port),
                                        host_pkey_directories=[],
                                        logger=self.log)

        return client
def get_tunnel ( self , remote_port , remote_host = "localhost" , local_port = None ) : if local_port : local_bind_address = ( 'localhost' , local_port ) else : local_bind_address = ( 'localhost' , ) if self . password and self . password . strip ( ) : client = SSHTunnelForwarder ( self . remote_host , ssh_port = self . port , ssh_username = self . username , ssh_password = self . password , ssh_pkey = self . key_file , ssh_proxy = self . host_proxy , local_bind_address = local_bind_address , remote_bind_address = ( remote_host , remote_port ) , logger = self . log ) else : client = SSHTunnelForwarder ( self . remote_host , ssh_port = self . port , ssh_username = self . username , ssh_pkey = self . key_file , ssh_proxy = self . host_proxy , local_bind_address = local_bind_address , remote_bind_address = ( remote_host , remote_port ) , host_pkey_directories = [ ] , logger = self . log ) return client
Creates a tunnel between two hosts. Like ssh -L <LOCAL_PORT>:host:<REMOTE_PORT>.

        :param remote_port: The remote port to create a tunnel to
        :type remote_port: int
        :param remote_host: The remote host to create a tunnel to (default localhost)
        :type remote_host: str
        :param local_port:  The local port to attach the tunnel to
        :type local_port: int

        :return: sshtunnel.SSHTunnelForwarder object
Creates a tunnel between two hosts . Like ssh - L <LOCAL_PORT > : host : <REMOTE_PORT > .