Tunnel(host, in_q, out_q, user=None, password=None, port=None, pkey=None, num_retries=3, retry_delay=5, allow_agent=True, timeout=None, channel_retries=5)¶
SSH proxy implementation with direct TCP/IP tunnels.
Each tunnel object runs in its own thread and can open any number of direct tunnels to remote host:port destinations on local ports over the same SSH connection.
To use, append
(host, port)tuples into
Tunnel.in_qand read listen port for tunnel connection from
Tunnel.tunnel_openis a thread event that will be set once tunnel is ready.
- host (str) – Remote SSH host to open tunnels with.
- in_q (
collections.deque) – Deque for requesting new tunnel to given
- out_q (
collections.deque) – Deque for feeding back tunnel listening ports.
- user (str) – (Optional) User to login as. Defaults to logged in user
- password (str) – (Optional) Password to use for login. Defaults to no password
- port (int) – (Optional) Port number to use for SSH connection. Defaults
Nonewhich uses SSH default (22)
- pkey (str) – Private key file path to use. Note that the public key file
pair must also exist in the same location with name
- num_retries (int) – (Optional) Number of connection and authentication attempts before the client gives up. Defaults to 3.
- retry_delay (int) – Number of seconds to wait between retries. Defaults
- timeout (int) – SSH session timeout setting in seconds. This controls timeout setting of authenticated SSH sessions.
- allow_agent (bool) – (Optional) set to False to disable connecting to the system’s SSH agent.
Thread run target. Starts tunnel client and waits for incoming tunnel connection requests from