1.19. ssh_forward

This module provides functionality for forwarding network services over SSH.

1.19.1. Classes

class SSHTCPForwarder(server, username, password, remote_server, local_port=0, private_key=None, missing_host_key_policy=None)[source]

Bases: threading.Thread

Open an SSH connection and forward TCP traffic through it to a remote host. A private key for authentication can be specified as a string either by it’s OpenSSH fingerprint, as a file (prefixed with “file:”), or a raw key string (prefixed with “key:”). If no missing_host_key_policy is specified, paramiko.client.AutoAddPolicy will be used to accept all host keys.

Note

This is a threading.Thread object and needs to be started with a call to start() after it is initialized.

__init__(server, username, password, remote_server, local_port=0, private_key=None, missing_host_key_policy=None)[source]
Parameters:
  • server (tuple) – The SSH server to connect to.
  • username (str) – The username to authenticate with.
  • password (str) – The password to authenticate with.
  • remote_server (tuple) – The remote server to connect to through the specified SSH server.
  • local_port (int) – The local port to forward, if not set a random one will be used.
  • private_key (str) – An RSA key to prefer for authentication.
  • missing_host_key_policy – The policy to use for missing host keys.
local_server[source]

A tuple representing the local address of the listening service which is forwarding traffic to the specified remote host.

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

start()[source]

Start the thread’s activity.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.

1.19.2. Exceptions

class KingPhisherSSHKeyError(message='')[source]

Bases: king_phisher.errors.KingPhisherError

An exception that is thrown when there is a problem resolving a users SSH key file. The message attribute is formatted to be displayed to the user via a dialog.