Native Tunnel
This module provides general purpose functionality for tunneling connections via an intermediary SSH proxy.
Clients connect to a provided local port and get traffic forwarded to/from the target host via an SSH proxy.
- class pssh.clients.native.tunnel.LocalForwarder
Thread runner for a group of local port forwarding proxies.
Starts servers in their own gevent hub via thread run target.
Use
enqueue
to create new servers and get port to connect to viaout_q
once a target has been put into the input queue.SSHClient
is the client for the SSH host that will be proxying.- cleanup_server(client)
The purpose of this function is for a proxied client to notify the LocalForwarder that it is shutting down and its corresponding server can also be shut down.
- enqueue(client, host, port)
Add target host:port to tunnel via client to queue.
- Parameters:
client (
pssh.clients.native.single.SSHClient
) – The client to connect via.host (str) – Target host to open connection to.
port (int) – Target port to connect on.
- run()
Thread runner ensures a non main hub has been created for all subsequent greenlets and waits for (client, host, port) tuples to be put into self.in_q.
A server is created once something is in the queue and the port to connect to is put into self.out_q.
- shutdown()
Stop all tunnel servers.
- class pssh.clients.native.tunnel.TunnelServer(client, host, port, bind_address='127.0.0.1', num_retries=3)
Local port forwarding server for tunneling connections from remote SSH server.
Accepts connections on an available bind_address port once started and tunnels data to/from remote SSH host for each connection.
- property listen_port