Native Tunnel¶
-
class
pssh.clients.native.tunnel.
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 intoTunnel.in_q
and read listen port for tunnel connection fromTunnel.out_q
.Tunnel.tunnel_open
is a thread event that will be set once tunnel is ready.Parameters: - host (str) – Remote SSH host to open tunnels with.
- in_q (
collections.deque
) – Deque for requesting new tunnel to given((host, port))
- 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
to
None
which 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
<pkey>.pub
- 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
to
pssh.constants.RETRY_DELAY
- 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.
-
run
()¶ Thread run target. Starts tunnel client and waits for incoming tunnel connection requests from
Tunnel.in_q
.