def ssh_connect(remote_machine, remote_port, service=VoidService, config={}): """ Connects to an RPyC server over an SSH tunnel (created by plumbum). See `Plumbum tunneling <http://plumbum.readthedocs.org/en/latest/remote.html#tunneling>`_ for further details. .. note:: This function attempts to allocate a free TCP port for the underlying tunnel, but doing so is inherently prone to a race condition with other processes who might bind the same port before sshd does. Albeit unlikely, there is no sure way around it. :param remote_machine: an :class:`plumbum.remote.RemoteMachine` instance :param remote_port: the port of the remote server :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ # with _ssh_connect_lock: ssh_connect_lock.__enter__() loc_port = _get_free_port() tun = remote_machine.tunnel(loc_port, remote_port) stream = TunneledSocketStream.connect("localhost", loc_port) stream.tun = tun ssh_connect_lock.__exit__() return Connection(service, Channel(stream), config=config)
def ssh_connect(sshctx, remote_port, service = VoidService, config = {}): """ Connects to an RPyC server over an SSH tunnel :param sshctx: an :class:`rpyc.utils.ssh.SshContext` instance :param remote_port: the port of the remote server :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ loc_port = _get_free_port() tun = sshctx.tunnel(loc_port, remote_port) stream = TunneledSocketStream.connect("localhost", loc_port) stream.tun = tun return Connection(service, Channel(stream), config = config)
def ssh_connect(sshctx, remote_port, service=VoidService, config={}): """ Connects to an RPyC server over an SSH tunnel :param sshctx: an :class:`rpyc.utils.ssh.SshContext` instance :param remote_port: the port of the remote server :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ loc_port = _get_free_port() tun = sshctx.tunnel(loc_port, remote_port) stream = TunneledSocketStream.connect("localhost", loc_port) stream.tun = tun return Connection(service, Channel(stream), config=config)
def ssh_connect(remote_machine, remote_port, service=VoidService, config={}): """ Connects to an RPyC server over an SSH tunnel (created by plumbum). See `http://plumbum.readthedocs.org/en/latest/remote.html#tunneling`_ for more details. :param remote_machine: an :class:`plumbum.remote.RemoteMachine` instance :param remote_port: the port of the remote server :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ loc_port = _get_free_port() tun = remote_machine.tunnel(loc_port, remote_port) stream = TunneledSocketStream.connect("localhost", loc_port) stream.tun = tun return Connection(service, Channel(stream), config=config)
def ssh_connect(remote_machine, remote_port, service = VoidService, config = {}): """ Connects to an RPyC server over an SSH tunnel (created by plumbum). See `http://plumbum.readthedocs.org/en/latest/remote.html#tunneling`_ for more details. :param remote_machine: an :class:`plumbum.remote.RemoteMachine` instance :param remote_port: the port of the remote server :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ loc_port = _get_free_port() tun = remote_machine.tunnel(loc_port, remote_port) stream = TunneledSocketStream.connect("localhost", loc_port) stream.tun = tun return Connection(service, Channel(stream), config = config)
def ssh_connect(remote_machine, remote_port, service = VoidService, config = {}): """ Connects to an RPyC server over an SSH tunnel (created by plumbum). See `Plumbum tunneling <http://plumbum.readthedocs.org/en/latest/remote.html#tunneling>`_ for further details. .. note:: This function attempts to allocate a free TCP port for the underlying tunnel, but doing so is inherently prone to a race condition with other processes who might bind the same port before sshd does. Albeit unlikely, there is no sure way around it. :param remote_machine: an :class:`plumbum.remote.RemoteMachine` instance :param remote_port: the port of the remote server :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ with _ssh_connect_lock: loc_port = _get_free_port() tun = remote_machine.tunnel(loc_port, remote_port) stream = TunneledSocketStream.connect("localhost", loc_port) stream.tun = tun return Connection(service, Channel(stream), config = config)