ssh.tunnel#

Module: zmq.ssh.tunnel#

Basic ssh tunnel utilities, and convenience functions for tunneling zeromq connections.

Functions#

zmq.ssh.tunnel.open_tunnel(addr, server, keyfile=None, password=None, paramiko=None, timeout=60)#

Open a tunneled connection from a 0MQ url.

For use inside tunnel_connection.

Returns:

(url, tunnel) – The 0MQ url that has been forwarded, and the tunnel object

Return type:

(str, object)

zmq.ssh.tunnel.select_random_ports(n)#

Select and return n random ports that are available.

zmq.ssh.tunnel.try_passwordless_ssh(server, keyfile, paramiko=None)#

Attempt to make an ssh connection without a password. This is mainly used for requiring password input only once when many tunnels may be connected to the same server.

If paramiko is None, the default for the platform is chosen.

zmq.ssh.tunnel.tunnel_connection(socket, addr, server, keyfile=None, password=None, paramiko=None, timeout=60)#

Connect a socket to an address via an ssh tunnel.

This is a wrapper for socket.connect(addr), when addr is not accessible from the local machine. It simply creates an ssh tunnel using the remaining args, and calls socket.connect(’tcp://localhost:lport’) where lport is the randomly selected local port of the tunnel.